#create collection of circles corresponding to markersĬircles = collections. Plt.scatter(x, tests, c = colors, s = markersize) Provides a simple way to change properties of all label text in a figure window. Line, = plt.plot(x, models, linestyle = 'dashed', color = 'black', label = 'Model') Tests = Ĭolors = cm.brg(np.linspace(0, 1, len(models))) You can use a circle collection to represent the markers, and then have a legend label for the collection as a whole.Įxample code: import matplotlib.pyplot as plt ![]() I have a solution for you if you're willing to use all circles for markers and differentiate by color only. X_data1 = np.random.rand(num_samples) * 130 ![]() I looked at answers using the 'DisplayName' property while plotting, but I didn't want to rewrite all of my plotting, and in any case ewasn't sure how to use it with plotyy (probably using hax plot / semilogy construct). Here is the plot generated and the code used to generate it: I had a similar problem, to create a legend, but not knowing how many plots I would have. You'll need to create your own class, like they do, that defines the legend_artist method, which then adds squares and circles as appropriate. I think it's best to use a full legend - otherwise, how will your readers know the difference between the two models, or the two datasets? I would do it this way:īut, if you really want to do it your way, you can use a custom legend as shown in this guide.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |