python:matplotlib

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
python:matplotlib [2023/07/20 10:47] – [Labels des axes] add yticks phswpython:matplotlib [2024/10/06 15:47] (Version actuelle) – [Matplotlib] add link phsw
Ligne 2: Ligne 2:
  
   * [[https://hal.inria.fr/hal-03427242/document|Scientific Visualization: Python + Matplotlib]]   * [[https://hal.inria.fr/hal-03427242/document|Scientific Visualization: Python + Matplotlib]]
 +  * [[https://duetosymmetry.com/code/latex-mpl-fig-tips/|Fonts/sizes in matplotlib figures for LaTeX publications]]
 +  * https://datavizcatalogue.com/FR/
 +
  
  
Ligne 315: Ligne 318:
 for tick in ax.get_xticklabels(): for tick in ax.get_xticklabels():
     tick.set_rotation(45)     tick.set_rotation(45)
 +    
 +# or (with Matplotlib >= 3.5):
 +ax.set_xticks(ax.get_xticks(), ax.get_xticklabels(), rotation=45, ha='right')
  
 # Pad margins so that markers don't get clipped by the axes # Pad margins so that markers don't get clipped by the axes
Ligne 575: Ligne 581:
 </code> </code>
  
 +
 +
 +=== Boxplots ===
 +
 +Pour que Matplotlib calcule directement les statistiques : ''ax.boxplot()'' ([[https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.boxplot.html#__do_not_save__|documentation]])
 +
 +Pour fournir nous-mêmes les statistiques à Matplotlib : ''ax.bxp()'' ([[https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.bxp.html#__do_not_save__|documentation]])
 +
 +
 +== Changer la couleur de fond ==
 +
 +[[https://matplotlib.org/stable/gallery/statistics/boxplot_color.html#sphx-glr-gallery-statistics-boxplot-color-py|Source]]
 +
 +<code python>
 +boxplot = ax1.boxplot(all_data, patch_artist=True)
 +for b in boxplot['boxes']:
 +    b.set_facecolor(color)
 +</code>
 +
 +== Légende correspondante ==
 +
 +[[https://stackoverflow.com/questions/47528955/adding-a-legend-to-a-matplotlib-boxplot-with-multiple-plots-on-same-axes|Source]]
 +
 +<code python>
 +boxplot = ax.boxplot(all_data, patch_artist=True)
 +ax.legend([boxplot["boxes"][0]], ["Label"])
 +</code>
  
  
  • python/matplotlib.1689842864.txt.gz
  • Dernière modification : 2023/07/20 10:47
  • de phsw