This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
other:python:matplotlib_by_jyp [2021/05/11 15:03] jypeter [Useful matplotlib reference pages] More ticks and labels stuff |
other:python:matplotlib_by_jyp [2021/12/21 15:46] jypeter [Working with matplotlib (JYP version)] Added link to cheatsheets |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Working with matplotlib (JYP version) ====== | ====== Working with matplotlib (JYP version) ====== | ||
+ | |||
+ | <note tip>Note: [[https://matplotlib.org/cheatsheets/|Matplotlib cheatsheets]]</note> | ||
**Summary**: there are lots of python libraries that you can use for plotting, but Matplotlib has become a //de facto// standard | **Summary**: there are lots of python libraries that you can use for plotting, but Matplotlib has become a //de facto// standard | ||
Line 142: | Line 144: | ||
['START', '0.2', '0.4', '0.6', 'END'] | ['START', '0.2', '0.4', '0.6', 'END'] | ||
</code> | </code> | ||
+ | * You can also use fancy [[https://matplotlib.org/stable/gallery/ticks_and_spines/tick-formatters.html|tick formatters]] | ||
* Many more options for ticks, labels, orientation, ... | * Many more options for ticks, labels, orientation, ... | ||
* **Grid lines**: | * **Grid lines**: | ||
Line 157: | Line 160: | ||
* [[https://matplotlib.org/api/_as_gen/matplotlib.pyplot.plot.html|plot(...)]]: //fmt// (see documentation) or ''marker'' and ''markerfacecolor''/''mfc'' (and ''markerfacecoloralt''/''mfcalt'' for dual color markers), ''markersize'', ''markeredgewidth''/''mew'', ''markeredgecolor'' (use ''markeredgecolor='none''' if you don't want to plot the edge of the markers), ''fillstyle'' (''full'', ''None'', [[https://matplotlib.org/stable/gallery/lines_bars_and_markers/marker_reference.htm|other]]) | * [[https://matplotlib.org/api/_as_gen/matplotlib.pyplot.plot.html|plot(...)]]: //fmt// (see documentation) or ''marker'' and ''markerfacecolor''/''mfc'' (and ''markerfacecoloralt''/''mfcalt'' for dual color markers), ''markersize'', ''markeredgewidth''/''mew'', ''markeredgecolor'' (use ''markeredgecolor='none''' if you don't want to plot the edge of the markers), ''fillstyle'' (''full'', ''None'', [[https://matplotlib.org/stable/gallery/lines_bars_and_markers/marker_reference.htm|other]]) | ||
* [[https://matplotlib.org/api/_as_gen/matplotlib.pyplot.scatter.html|scatter(...)]]: ''marker'' (marker type), ''c'' (color), ''s'' (size), ''linewidths'' (linewidth of the marker edges), ''edgecolors'' | * [[https://matplotlib.org/api/_as_gen/matplotlib.pyplot.scatter.html|scatter(...)]]: ''marker'' (marker type), ''c'' (color), ''s'' (size), ''linewidths'' (linewidth of the marker edges), ''edgecolors'' | ||
- | * [[https://matplotlib.org/api/colors_api.html|colors]] and colormaps | + | * [[https://matplotlib.org/stable/api/colors_api.html|colors]] and colormaps |
* [[https://matplotlib.org/stable/gallery/color/color_demo.html|color demo]] | * [[https://matplotlib.org/stable/gallery/color/color_demo.html|color demo]] | ||
- | * [[https://matplotlib.org/examples/color/named_colors.html|named colors]] | + | * [[https://matplotlib.org/stable/gallery/color/named_colors.html#sphx-glr-gallery-color-named-colors-py|named colors]] |
+ | * [[https://www.w3schools.com/colors/colors_picker.asp|HTML color picker]] and different ways of choosing colors | ||
* Reverting the colors: add ''_r'' at the end of the colormap name | * Reverting the colors: add ''_r'' at the end of the colormap name | ||
* Number of colors in the //my_cmap// colormap (usually 256): ''my_cmap.N'' | * Number of colors in the //my_cmap// colormap (usually 256): ''my_cmap.N'' | ||
Line 246: | Line 250: | ||
[[https://stackoverflow.com/questions/9797520/masking-part-of-a-contourf-plot-in-matplotlib|trick source]] | [[https://stackoverflow.com/questions/9797520/masking-part-of-a-contourf-plot-in-matplotlib|trick source]] | ||
+ | ===== Unsorted matplotlib stuff ===== | ||
+ | |||
+ | Some useful notes and links that cannot be placed (yet) in a section of the main page | ||
+ | |||
+ | ==== Plotting arcs (segments of ellipses) ==== | ||
+ | |||
+ | * [[https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Arc.html|Offical patches.Arc documentation]] | ||
+ | * A nice [[https://stackoverflow.com/questions/54849976/can-someone-explain-the-different-parameters-in-matplotlib-patches-arc|ellipses and arcs tutorial]] on stackoverflow | ||
+ | |||
+ | ==== Using hatches with contourf ==== | ||
+ | |||
+ | * [[https://matplotlib.org/stable/gallery/shapes_and_collections/hatch_style_reference.html|Hatch style reference]] | ||
+ | * [[https://matplotlib.org/stable/gallery/shapes_and_collections/hatch_demo.html|Hatch demo]] | ||
+ | * [[https://matplotlib.org/stable/gallery/images_contours_and_fields/contourf_hatching.html|Contourf hatching]] | ||
+ | * //Collections// trick for [[https://fantashit.com/hatching-color-in-contourf-function/|changing the colors of hatches]] | ||
/* standard page footer */ | /* standard page footer */ |