Issue
I have to plot different curves in one matplotlib figure. Each curve must have its own style (color, thickness, etc..) and I would like to set the styles in one matplotlibrc file. I would like to use a name like line1, line2, etc.. to refer to different styles, and not to a color cycle. Is this possible in motplotlib?
Solution
The matplotlib rc file is meant to provide the default style for a plot, its not meant to provide styles in the way of Cascading Style Sheets (CSS) or classes.
So what is possible, is to create several rc files and use them in a context, as explained in the temporary-styling part of the customizing tutorial, e.g. using a file called line1.mplstyle
you could do
with plt.style.context(('line1')):
plt.plot([1,2,3])
Because this seems to be a little overkill for just setting some line properties, it might be sufficient to simply create some argument dictionaries to provide to the plot command, like so:
line1 = dict(lw=2, ls=":", color="red")
line2 = dict(lw=0.8, ls="-", color="blue")
ax.plot([1,2,3], **line1)
ax.plot([1,2,3], **line2)
Answered By - ImportanceOfBeingErnest
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.