![]() Sc2 = axes.scatter(x,y, marker="x", color="k")įinally you may set the labels within the legend call: import numpy as npĪxes. Sc1 = axes.scatter(x,y, marker="o", color="r") If you want to set the label after creating the scatter, but before creating the legend, you may use set_label on the PathCollection returned by the scatter import numpy as np import numpy as npĪxes.scatter(x,y, marker="o", color="r", label="Admitted")Īxes.scatter(x,y, marker="x", color="k", label="Not-Admitted")Īxes.set(xlabel="Exam score-1", ylabel="Exam score-2") The most convenient way to get a legend entry for a plot is to use the label argument. Simple function to get rid of superfluous xticks but retain the ones on the bottom (works in pylab).You are setting the label for the axes, not the scatters. You can do it in multiple ways: Here is one solution making use of tickparams: ax.tickparams (labelrotation45) Here is another solution making use of setxticklabels: ax.setxticklabels (labels, rotation45) Here is a third solution making use of setrotation: for tick in ax. Thanks to Sebastian Krieger from matplotlib-users list for this trick. set_xlabel( ' And a shared x label ', fontsize= 14) So this: for axs in ax.flat: axs.set (ylabel'AUC') changes to: ax 0.setylabel ('AUC') I also recommend you to share the axis between your multiple subplots, since all the yticks are making your plot a little less readable than ideal. set_ylabel( ' This is a long label shared among more axes ', fontsize= 14) 21 cx. What you need is to only label the first cell in your subplot row. get_xticklabels(), visible= False) 19 20 bx. get_xticklabels(), visible= False) 18 pylab. add_subplot( 3, 1, 3, sharex= ax, sharey= ax) 12 13 ax. I am trying to plot a pandas dataframe having a subplot per column in the dataframe. However, another thing you can label is the line/point/bar/etc that you plot. By default () using the subplots option doesn't seem to make it easy to plot a ylabel per subplot. add_subplot( 3, 1, 2, sharex= ax, sharey= ax) 11 cx = fig. fig, axes plt.subplots(nrows3) for ax in axes: ax.plot(-10, -5, 0, 5. subplots_adjust(** adjustprops) # Tunes the subplot layout 8 9 ax = fig. Also see the attached figure output.ġ import pylab 2 3 figprops = dict( figsize=( 8., 8. errorbar( times300, average300)Īlternatively, you can use the following snippet to have shared ylabels on your subplots. ![]() get_position() 20 position = 0.15 21 position = position + 0.03 22 bottomSubplot. subplot( 2, 1, 2) 19 position = bottomSubplot. errorbar( times150, average150) 18 bottomSubplot = pylab. get_position() 14 position = 0.15 15 position = position + 0.01 16 topSubplot. subplot( 2, 1, 1) 13 position = topSubplot. ylabel( r' \ textbf ', size= ' medium ') 10 # Create subplots and shift them up and to the right to keep tick labels 11 # from overlapping the axis labels defined above 12 topSubplot = pylab. yticks() 7 # I'm using TeX for typesetting the labels-not necessary 8 pylab. xticks() # don't want to see any ticks on this axis 6 pylab. ![]() axes( frameon= False) # hide frame 5 pylab. 1 # note that this a code fragment.you will have to define your own data to plot 2 # Set up a whole-figure axes, with invisible axis, ticks, and ticklabels, 3 # which we use to get the xlabel and ylabel in the right place 4 bigAxes = pylab. Operating system: Matplotlib version: Matplotlib backend ( print (matplotlib.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |