This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
other:python:matplotlib_by_jyp [2020/02/11 12:55] jypeter [Starting (and more) with matplotlib] |
other:python:matplotlib_by_jyp [2020/03/31 10:49] jypeter [Misc Matplotlib tricks] Improved |
||
---|---|---|---|
Line 187: | Line 187: | ||
===== Misc Matplotlib tricks ===== | ===== Misc Matplotlib tricks ===== | ||
- | * Specifying the background color of a plot (e.g. when plotting a masked variable and you don't want the masked areas to be white) | + | ==== Specifying the background color of a plot ==== |
- | * ''# make the background dark gray (call this before the contourf)''\\ ''plt.gca().patch.set_color('.25')''\\ ''plt.contourf(d)''\\ ''plt.show()'' | + | |
- | * [[https://stackoverflow.com/questions/9797520/masking-part-of-a-contourf-plot-in-matplotlib|trick source]] | + | e.g. You need to plot a masked variable, but you don't want the masked areas to be white |
+ | |||
+ | <code># make the background dark gray (call this before the contourf) | ||
+ | plt.gca().patch.set_color('.25') | ||
+ | plt.contourf(d) | ||
+ | plt.show()</code> | ||
+ | |||
+ | [[https://stackoverflow.com/questions/9797520/masking-part-of-a-contourf-plot-in-matplotlib|trick source]] | ||