python - Plot circles with matplotlib from text file -


I am trying to plot circles in matplotlib using the file as the source of data, The difficulties are getting. / P>

This is my code

  open ('DataSample2.txt', 'r') as file: file.readline () # First row xy = [[Line] for the line [x] for the line (x) flag (x) ('') [: 2]] for the line in the file] rad = [[float (x) x line.split ('') [ 2: 3]] In the file for the row] Print (XI) Print (RD) # Serial = PLT Chakra (XI [0], Rad [0], Color = 'G') #fig = plt.gcf () # fig.gca (). Add_artist # Angeet Interview ('plotcircles.png')   

And this is my data source:

  xy rad 2 5 2 2 2 2 3 1 3 5 2 1 6 4 3   

My problem, perhaps, is how I am creating xy and rad lists.

I do not think you need a list of plot circles.

  Import matplotlib.pyplot as plty as numpy.random import rand ('DataSample2.txt', 'r') as f: Next (F) xmin = ymin = 999999999 Xmax = yma x = -999999999 f: x, y, r = map (float, line split ()) circle = plt.circle ((x, y), r, color = rand (3)) fig = plt gcf () Fig.gca (). Add_artist (circle) xmin = min (xr, xmin) xmax = max (x + r, xmax) ymin = min (yr, ymin) ymax = max (y + r, ymax) # break # if you only draw one circle If you want to break here, plt.xlim (xmin, xmax) plt.ylim (ymin, ymax) plt.show ()   

 Enter image details here

Comments

Popular posts from this blog

sonata admin - how to add ManyToOne property field in configureListfield in sonataAdmin -

wpf - ControlTemplate with changes for every class -

python - how we can use ajax() in views.py in django? -