scatterplot instead of a lineplot while using the plotfile function of matplotlib
I know th开发者_运维问答e general usage of plotfile:
import matplotlib.pyplot as plt
plt.plotfile(csvfile,sometuple)
But this produces a line plot by default. I want a scatterplot. Is there some special argument that i need to pass to this method? I have already looked into the documentation and didnt find anything.
I don't see the advantages of plotfile, myself: as soon as you want to do anything interesting it's probably easier to work with the usual directives. But
matplotlib.pyplot.plotfile('dat.csv',(0,1),linestyle="",marker="o")
should replace the line by points.
I don't know how to use the plotfile command, but in the 'just' plot I've used markers like
matplotlib.pyplot.plot(X1, Y1, 'go', X2, Y2, 'b-')
where 'go' means green circles for the first plots, 'b-' means blue lines for the second plot, 'r--' means red dashed lines, and so on...
Check out the matplotlib.pyplot.plot
documentation.
Plotfile is now deprecated, but for people reading this trying to make a scatter plot in regular matplotlib, it's easily done with .scatter
. See the docs here.
In your code, try adding this, though you'll need to make sure csvfile
and sometuple
have the same dimensions.
plt.scatter(csvfile, sometuple)
精彩评论