About 418,000 results
Open links in new tab
  1. python - Adding a matplotlib legend - Stack Overflow

    How can one create a legend for a line graph in Matplotlib's PyPlot without creating any extra variables? Please consider the graphing script below: if __name__ == '__main__': …

  2. How do you create a legend for a contour plot? - Stack Overflow

    Jun 3, 2022 · python matplotlib legend contour edited Aug 18, 2023 at 17:04 Trenton McKinney 63.2k 41 170 213

  3. How do I make a single legend for many subplots? - Stack Overflow

    I am plotting the same type of information, but for different countries, with multiple subplots with Matplotlib. That is, I have nine plots on a 3x3 grid, all with the same for lines (of course,

  4. How to add legend to imshow() in matplotlib - Stack Overflow

    Aug 25, 2014 · 20 I am using matplotlib In plot() or bar(), we can easily put legend, if we add labels to them. but what if it is a contourf() or imshow() I know there is a colorbar() which can …

  5. How to change legend fontsize with matplotlib.pyplot

    plt.legend(fontsize=20) # using a size in points plt.legend(fontsize="x-large") # using a named size With this method you can set the fontsize for each legend at creation (allowing you to have …

  6. How to put the legend outside the plot - Stack Overflow

    The legend handles and labels need to obtained from the real plot via h, l = ax.get_legend_handles_labels() and can then be supplied to the legend in the lax subplot, …

  7. How to place two different legends on the same graph

    I actually build the legend based on colors, associating each color with the corresponding parameter. Now I'd like to display a second legend on the same graph, with the meaning of …

  8. python - Reverse the order of a legend - Stack Overflow

    plt.legend(title="Line", loc='upper left', reverse=True) The default is reverse=False (the previous behaviour)—setting it to reverse=True will now show the entries in the legend in the same …

  9. python - How to manually create a legend - Stack Overflow

    I am using matplotlib and I would like to manually add items to the legend that are a color and a label. I am adding data to to the plot to specifying there would lead to a lot of duplicates. My th...

  10. How to specify legend position in graph coordinates

    According to the matplotlib legend documentation: The location can also be a 2-tuple giving the coordinates of the lower-left corner of the legend in axes coordinates (in which case …