2026-03-04: Continued

This commit is contained in:
Moussouni, Yaël
2026-03-04 18:12:16 +01:00
parent b3bca439b1
commit b58b2f02a8

View File

@@ -52,15 +52,20 @@ class ManchotRC:
self.n_cols = 1
self.aspect = 3/2
self.page_linewidth = (self.paper[0] - self.margin_left - self.margin_right)
self.page_textwidth = self.page_linewidth/self.n_cols - self.margin_cols*(self.n_cols - 1)
# Global parameters
self.linewidth = 2
self.markersize = 3
self.pad = 3.5
self.joinstyle = "round"
self.fig_x = self.page_textwidth
self.fig_y = self.fig_x / self.aspect
# Colours
self.colour_fg = "#000000"
self.colour_mg = "#7F7F7F"
self.colour_bg = "#FFFFFF"
self.colours = [c.signal_blue,
c.signal_orange,
@@ -71,6 +76,21 @@ class ManchotRC:
c.signal_pink,
c.signal_grey]
self.colour_fg_rgb = np.array(mpl.colors.to_rgb(self.colour_fg))
self.colour_bg_rgb = np.array(mpl.colors.to_rgb(self.colour_bg))
self.colour_mg_rgb = np.mean([self.colour_fg_rgb, self.colour_bg_rgb],
axis=0)
self.colour_mg = mpl.colors.to_hex(self.colour_mg_rgb)
self.colour_mbg_rgb = np.mean([self.colour_mg_rgb, self.colour_bg_rgb],
axis=0)
self.colour_mbg = mpl.colors.to_hex(self.colour_mbg_rgb)
self.colour_mfg_rgb = np.mean([self.colour_mg_rgb, self.colour_fg_rgb],
axis=0)
self.colour_mfg = mpl.colors.to_hex(self.colour_mfg_rgb)
# Lines
self.lines_linewidth = self.linewidth
self.lines_markersize = self.markersize
@@ -190,7 +210,7 @@ class ManchotRC:
self.axes_labelsize = "medium"
self.axes_labelweight = "normal"
self.axes_labelpad = self.pad
self.axes_axisbelow = "line"
self.axes_axisbelow = True
self.axes_facecolor = self.colour_bg
self.axes_edgecolor = self.colour_fg
self.axes_titlecolor = self.axes_edgecolor
@@ -218,9 +238,9 @@ class ManchotRC:
self.axes3d_grid = True
self.axes3d_automargin = False
self.axes3d_xaxis_panecolor = (0.95,0.95,0.95,0.5)
self.axes3d_yaxis_panecolor = (0.90,0.90,0.90,0.5)
self.axes3d_zaxis_panecolor = (0.925,0.925,0.925,0.5)
self.axes3d_xaxis_panecolor = np.concatenate([self.colour_mg_rgb, [0.05]])
self.axes3d_yaxis_panecolor = np.concatenate([self.colour_mg_rgb, [0.10]])
self.axes3d_zaxis_panecolor = np.concatenate([self.colour_mg_rgb, [0.15]])
self.axes3d_mouserotationstyle = "trackball"
self.axes3d_trackballsize = 0.667
self.axes3d_trackballborder = 0.2
@@ -286,24 +306,65 @@ class ManchotRC:
self.ytick_alignment = "center_baseline"
# Grids
self.grid_color = self.colour_fg
self.grid_color = self.colour_mbg
self.grid_linestyle = ":"
self.grid_linewidth = self.linewidth/2
self.grid_alpha = 0.2
self.grid_alpha = 1
# Legend
self.legend_loc = "best"
self.legend_frameon = True
self.legend_framealpha = 0.8
self.legend_facecolor = self.colour_bg
self.legend_edgecolor = self.colour_mbg
self.legend_fancybox = True
self.legend_shadow = False
self.legend_numpoints = 1
self.legend_scatterpoints = 1
self.legend_markerscale = 1.0
self.legend_fontsize = "medium"
self.legend_labelcolor = self.colour_fg
self.legend_title_fontsize = None
self.legend_borderpad = 0.4
self.legend_labelspacing = 0.5
self.legend_handlelength = 2.0
self.legend_handleheight = 0.7
self.legend_handletextpad = 0.8
self.legend_borderaxespad = 0.5
self.legend_columnspacing = 2.0
# Figure
self.figure_titlesize = "medium"
self.figure_titleweight = "normal"
self.figure_labelsize = "medium"
self.figure_labelweight = "normal"
self.figure_figsize = self.fig_x, self.fig_y
self.figure_dpi = 150
self.figure_facecolor = self.colour_bg
self.figure_edgecolor = self.colour_bg
self.figure_frameon = True
self.figure_subplot_left = 0.125
self.figure_subplot_right = 0.9
self.figure_subplot_bottom = 0.11
self.figure_subplot_top = 0.88
self.figure_subplot_wspace = 0.2
self.figure_subplot_hspace = 0.2
self.figure_autolayout = False
self.figure_constrained_layout_use = True
self.figure_constrained_layout_h_pad = 0.04
self.figure_constrained_layout_w_pad = 0.04
self.figure_constrained_layout_hspace = 0.02
self.figure_constrained_layout_wspace = 0.02
# XXX START BACK HERE
# XXX <https://matplotlib.org/stable/users/explain/customizing.html>
# Figure
self.figure_dpi = 150
# FIXME: TMP
self.savefig_dpi = 300
self.savefig_transparent = True
# Compute
self._compute()
return None
@@ -420,12 +481,6 @@ class ManchotRC:
self.context["axes.prop_cycle"] = self.axes_prop_cycle
# Figure
self.context["figure.figsize"] = (figsize_x, figsize_y)
self.context["figure.dpi"] = self.figure_dpi
self.context["savefig.dpi"] = self.savefig_dpi
self.context["savefig.transparent"] = self.savefig_transparent
# Axes
self.context["axes.formatter.limits"] = self.axes_formatter_limits
@@ -471,6 +526,7 @@ class ManchotRC:
self.context["date.converter"] = self.date_converter
self.context["date.interval_multiples"] = self.date_interval_multiples
# Ticks
self.context["xtick.top"] = self.xtick_top
self.context["xtick.bottom"] = self.xtick_bottom
self.context["xtick.labeltop"] = self.xtick_labeltop
@@ -514,11 +570,67 @@ class ManchotRC:
self.context["ytick.minor.right"] = self.ytick_minor_right
self.context["ytick.minor.ndivs"] = self.ytick_minor_ndivs
self.context["ytick.alignment"] = self.ytick_alignment
# Grid
self.context["grid.color"] = self.grid_color
self.context["grid.linestyle"] = self.grid_linestyle
self.context["grid.linewidth"] = self.grid_linewidth
self.context["grid.alpha"] = self.grid_alpha
# Legend
self.context["legend.loc"] = self.legend_loc
self.context["legend.frameon"] = self.legend_frameon
self.context["legend.framealpha"] = self.legend_framealpha
self.context["legend.facecolor"] = self.legend_facecolor
self.context["legend.edgecolor"] = self.legend_edgecolor
self.context["legend.fancybox"] = self.legend_fancybox
self.context["legend.shadow"] = self.legend_shadow
self.context["legend.numpoints"] = self.legend_numpoints
self.context["legend.scatterpoints"] = self.legend_scatterpoints
self.context["legend.markerscale"] = self.legend_markerscale
self.context["legend.fontsize"] = self.legend_fontsize
self.context["legend.labelcolor"] = self.legend_labelcolor
self.context["legend.title_fontsize"] = self.legend_title_fontsize
self.context["legend.borderpad"] = self.legend_borderpad
self.context["legend.labelspacing"] = self.legend_labelspacing
self.context["legend.handlelength"] = self.legend_handlelength
self.context["legend.handleheight"] = self.legend_handleheight
self.context["legend.handletextpad"] = self.legend_handletextpad
self.context["legend.borderaxespad"] = self.legend_borderaxespad
self.context["legend.columnspacing"] = self.legend_columnspacing
# Figure
self.context["figure.titlesize"] = self.figure_titlesize
self.context["figure.titleweight"] = self.figure_titleweight
self.context["figure.labelsize"] = self.figure_labelsize
self.context["figure.labelweight"] = self.figure_labelweight
self.context["figure.figsize"] = self.figure_figsize
self.context["figure.dpi"] = self.figure_dpi
self.context["figure.facecolor"] = self.figure_facecolor
self.context["figure.edgecolor"] = self.figure_edgecolor
self.context["figure.frameon"] = self.figure_frameon
self.context["figure.subplot.left"] = self.figure_subplot_left
self.context["figure.subplot.right"] = self.figure_subplot_right
self.context["figure.subplot.bottom"] = self.figure_subplot_bottom
self.context["figure.subplot.top"] = self.figure_subplot_top
self.context["figure.subplot.wspace"] = self.figure_subplot_wspace
self.context["figure.subplot.hspace"] = self.figure_subplot_hspace
self.context["figure.autolayout"] = self.figure_autolayout
self.context["figure.constrained_layout.use"] = self.figure_constrained_layout_use
self.context["figure.constrained_layout.h_pad"] = self.figure_constrained_layout_h_pad
self.context["figure.constrained_layout.w_pad"] = self.figure_constrained_layout_w_pad
self.context["figure.constrained_layout.hspace"] = self.figure_constrained_layout_hspace
self.context["figure.constrained_layout.wspace"] = self.figure_constrained_layout_wspace
# FIXME: TMP
self.context["savefig.dpi"] = self.savefig_dpi
self.context["savefig.transparent"] = self.savefig_transparent
return None
@@ -529,14 +641,15 @@ if __name__ == "__main__":
rc = ManchotRC()
with plt.style.context(rc.context):
fig, axs = plt.subplots(1, 3, layout="constrained")
fig, axs = plt.subplots(1, 3)
fig.suptitle("Default plot")
axs[0].plot([0,1,2,3,4], [2,1,4,3,6])
axs[0].plot([0,1,2,3,4], [4,3,1,2,4], "o--")
axs[0].plot([0,1,2,3,4], [2,1,4,3,6], label="curve 1")
axs[0].plot([0,1,2,3,4], [4,3,1,2,4], "o--", label="curve 2")
axs[0].set_title("Lorem")
axs[0].set_xlabel("$x~\\mathrm{[cm]}$")
axs[0].set_ylabel("$y~\\mathrm{[cm]}$")
axs[0].legend()
axs[1].scatter([0,1,2,3,4], [2,1,4,3,6])
axs[1].scatter([0,1,2,3,4], [4,3,1,2,4], s=[1,2,3,4,6])