mirror of
https://codeberg.org/Yael-II/Matplotlib-Style.git
synced 2026-03-15 05:46:26 +01:00
2026-02-08: Continued machot_plot
This commit is contained in:
@@ -55,6 +55,8 @@ class ManchotRC:
|
|||||||
# Global parameters
|
# Global parameters
|
||||||
self.linewidth = 2
|
self.linewidth = 2
|
||||||
self.markersize = 3
|
self.markersize = 3
|
||||||
|
self.pad = 3.5
|
||||||
|
self.joinstyle = "round"
|
||||||
|
|
||||||
# Colours
|
# Colours
|
||||||
self.colour_fg = "#000000"
|
self.colour_fg = "#000000"
|
||||||
@@ -75,13 +77,13 @@ class ManchotRC:
|
|||||||
self.lines_linestyle = "-"
|
self.lines_linestyle = "-"
|
||||||
self.lines_marker = ""
|
self.lines_marker = ""
|
||||||
self.lines_markeredgewidth = self.linewidth/2
|
self.lines_markeredgewidth = self.linewidth/2
|
||||||
self.lines_dash_joinstyle = "round"
|
self.lines_dash_joinstyle = self.joinstyle
|
||||||
self.lines_dash_capstyle = "round"
|
self.lines_dash_capstyle = self.joinstyle
|
||||||
self.lines_solid_joinstyle = "round"
|
self.lines_solid_joinstyle = self.joinstyle
|
||||||
self.lines_solid_capstyle = "round"
|
self.lines_solid_capstyle = self.joinstyle
|
||||||
self.lines_color = self.colours[0]
|
self.lines_color = self.colours[0]
|
||||||
self.lines_markerfacecolor = "auto"
|
self.lines_markerfacecolor = "auto"
|
||||||
self.lines_markeredgecolor = "auto"
|
self.lines_markeredgecolor = self.lines_markerfacecolor
|
||||||
|
|
||||||
# Patches
|
# Patches
|
||||||
self.patch_linewidth = self.linewidth
|
self.patch_linewidth = self.linewidth
|
||||||
@@ -184,10 +186,10 @@ class ManchotRC:
|
|||||||
self.axes_titley = None
|
self.axes_titley = None
|
||||||
self.axes_titlesize = "medium"
|
self.axes_titlesize = "medium"
|
||||||
self.axes_titleweight = "normal"
|
self.axes_titleweight = "normal"
|
||||||
self.axes_titlepad = 6.0
|
self.axes_titlepad = self.pad
|
||||||
self.axes_labelsize = "medium"
|
self.axes_labelsize = "medium"
|
||||||
self.axes_labelweight = "normal"
|
self.axes_labelweight = "normal"
|
||||||
self.axes_labelpad = 4.0
|
self.axes_labelpad = self.pad
|
||||||
self.axes_axisbelow = "line"
|
self.axes_axisbelow = "line"
|
||||||
self.axes_facecolor = self.colour_bg
|
self.axes_facecolor = self.colour_bg
|
||||||
self.axes_edgecolor = self.colour_fg
|
self.axes_edgecolor = self.colour_fg
|
||||||
@@ -219,13 +221,79 @@ class ManchotRC:
|
|||||||
self.axes3d_xaxis_panecolor = (0.95,0.95,0.95,0.5)
|
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_yaxis_panecolor = (0.90,0.90,0.90,0.5)
|
||||||
self.axes3d_zaxis_panecolor = (0.925,0.925,0.925,0.5)
|
self.axes3d_zaxis_panecolor = (0.925,0.925,0.925,0.5)
|
||||||
self.axes3d_mouserotationstyle = "arcball"
|
self.axes3d_mouserotationstyle = "trackball"
|
||||||
self.axes3d_trackballsize = 0.667
|
self.axes3d_trackballsize = 0.667
|
||||||
self.axes3d_trackballborder = 0.2
|
self.axes3d_trackballborder = 0.2
|
||||||
|
|
||||||
|
# Axis
|
||||||
|
self.xaxis_labellocation = "center"
|
||||||
|
self.yaxis_labellocation = "center"
|
||||||
|
|
||||||
|
# Dates
|
||||||
|
self.date_autoformatter_year = "%Y"
|
||||||
|
self.date_autoformatter_month = "%Y-%m"
|
||||||
|
self.date_autoformatter_day = "%Y-%m-%d"
|
||||||
|
self.date_autoformatter_hour = "%m-%d%H"
|
||||||
|
self.date_autoformatter_minute = "%d%H:%M"
|
||||||
|
self.date_autoformatter_second = "%H:%M:%S"
|
||||||
|
self.date_autoformatter_microsecond = "%M:%S.%f"
|
||||||
|
self.date_converter = "auto"
|
||||||
|
self.date_interval_multiples = True
|
||||||
|
|
||||||
|
# Ticks
|
||||||
|
self.xtick_top = True
|
||||||
|
self.xtick_bottom = True
|
||||||
|
self.xtick_labeltop = False
|
||||||
|
self.xtick_labelbottom = True
|
||||||
|
self.xtick_major_size = self.linewidth*2
|
||||||
|
self.xtick_minor_size = self.xtick_major_size/2
|
||||||
|
self.xtick_major_width = self.linewidth/2
|
||||||
|
self.xtick_minor_width = self.xtick_major_width
|
||||||
|
self.xtick_major_pad = self.pad
|
||||||
|
self.xtick_minor_pad = self.pad
|
||||||
|
self.xtick_color = self.colour_fg
|
||||||
|
self.xtick_labelcolor = self.xtick_color
|
||||||
|
self.xtick_labelsize = "medium"
|
||||||
|
self.xtick_direction = "in"
|
||||||
|
self.xtick_minor_visible = False
|
||||||
|
self.xtick_major_top = True
|
||||||
|
self.xtick_major_bottom = True
|
||||||
|
self.xtick_minor_top = True
|
||||||
|
self.xtick_minor_bottom = True
|
||||||
|
self.xtick_minor_ndivs = "auto"
|
||||||
|
self.xtick_alignment = "center"
|
||||||
|
|
||||||
|
self.ytick_left = self.xtick_bottom
|
||||||
|
self.ytick_right = self.xtick_top
|
||||||
|
self.ytick_labelleft = self.xtick_labelbottom
|
||||||
|
self.ytick_labelright = self.xtick_labeltop
|
||||||
|
self.ytick_major_size = self.xtick_major_size
|
||||||
|
self.ytick_minor_size = self.xtick_minor_size
|
||||||
|
self.ytick_major_width = self.xtick_major_width
|
||||||
|
self.ytick_minor_width = self.xtick_minor_width
|
||||||
|
self.ytick_major_pad = self.xtick_major_pad
|
||||||
|
self.ytick_minor_pad = self.xtick_minor_pad
|
||||||
|
self.ytick_color = self.xtick_color
|
||||||
|
self.ytick_labelcolor = self.xtick_labelcolor
|
||||||
|
self.ytick_labelsize = self.xtick_labelsize
|
||||||
|
self.ytick_direction = self.xtick_direction
|
||||||
|
self.ytick_minor_visible = self.xtick_minor_visible
|
||||||
|
self.ytick_major_left = self.xtick_major_bottom
|
||||||
|
self.ytick_major_right = self.xtick_major_top
|
||||||
|
self.ytick_minor_left = self.xtick_minor_bottom
|
||||||
|
self.ytick_minor_right = self.xtick_minor_top
|
||||||
|
self.ytick_minor_ndivs = self.xtick_minor_ndivs
|
||||||
|
self.ytick_alignment = "center_baseline"
|
||||||
|
|
||||||
|
# Grids
|
||||||
|
self.grid_color = self.colour_fg
|
||||||
|
self.grid_linestyle = ":"
|
||||||
|
self.grid_linewidth = self.linewidth/2
|
||||||
|
self.grid_alpha = 0.2
|
||||||
|
|
||||||
|
|
||||||
# XXX START BACK HERE
|
# XXX START BACK HERE
|
||||||
|
# XXX <https://matplotlib.org/stable/users/explain/customizing.html>
|
||||||
|
|
||||||
|
|
||||||
# Figure
|
# Figure
|
||||||
@@ -387,16 +455,84 @@ class ManchotRC:
|
|||||||
self.context["axes3d.mouserotationstyle"] = self.axes3d_mouserotationstyle
|
self.context["axes3d.mouserotationstyle"] = self.axes3d_mouserotationstyle
|
||||||
self.context["axes3d.trackballsize"] = self.axes3d_trackballsize
|
self.context["axes3d.trackballsize"] = self.axes3d_trackballsize
|
||||||
self.context["axes3d.trackballborder"] = self.axes3d_trackballborder
|
self.context["axes3d.trackballborder"] = self.axes3d_trackballborder
|
||||||
|
|
||||||
|
# Axis
|
||||||
|
self.context["xaxis.labellocation"] = self.xaxis_labellocation
|
||||||
|
self.context["yaxis.labellocation"] = self.yaxis_labellocation
|
||||||
|
|
||||||
|
# Dates
|
||||||
|
self.context["date.autoformatter.year"] = self.date_autoformatter_year
|
||||||
|
self.context["date.autoformatter.month"] = self.date_autoformatter_month
|
||||||
|
self.context["date.autoformatter.day"] = self.date_autoformatter_day
|
||||||
|
self.context["date.autoformatter.hour"] = self.date_autoformatter_hour
|
||||||
|
self.context["date.autoformatter.minute"] = self.date_autoformatter_minute
|
||||||
|
self.context["date.autoformatter.second"] = self.date_autoformatter_second
|
||||||
|
self.context["date.autoformatter.microsecond"] = self.date_autoformatter_microsecond
|
||||||
|
self.context["date.converter"] = self.date_converter
|
||||||
|
self.context["date.interval_multiples"] = self.date_interval_multiples
|
||||||
|
|
||||||
|
self.context["xtick.top"] = self.xtick_top
|
||||||
|
self.context["xtick.bottom"] = self.xtick_bottom
|
||||||
|
self.context["xtick.labeltop"] = self.xtick_labeltop
|
||||||
|
self.context["xtick.labelbottom"] = self.xtick_labelbottom
|
||||||
|
self.context["xtick.major.size"] = self.xtick_major_size
|
||||||
|
self.context["xtick.minor.size"] = self.xtick_minor_size
|
||||||
|
self.context["xtick.major.width"] = self.xtick_major_width
|
||||||
|
self.context["xtick.minor.width"] = self.xtick_minor_width
|
||||||
|
self.context["xtick.major.pad"] = self.xtick_major_pad
|
||||||
|
self.context["xtick.minor.pad"] = self.xtick_minor_pad
|
||||||
|
self.context["xtick.color"] = self.xtick_color
|
||||||
|
self.context["xtick.labelcolor"] = self.xtick_labelcolor
|
||||||
|
self.context["xtick.labelsize"] = self.xtick_labelsize
|
||||||
|
self.context["xtick.direction"] = self.xtick_direction
|
||||||
|
self.context["xtick.minor.visible"] = self.xtick_minor_visible
|
||||||
|
self.context["xtick.major.top"] = self.xtick_major_top
|
||||||
|
self.context["xtick.major.bottom"] = self.xtick_major_bottom
|
||||||
|
self.context["xtick.minor.top"] = self.xtick_minor_top
|
||||||
|
self.context["xtick.minor.bottom"] = self.xtick_minor_bottom
|
||||||
|
self.context["xtick.minor.ndivs"] = self.xtick_minor_ndivs
|
||||||
|
self.context["xtick.alignment"] = self.xtick_alignment
|
||||||
|
|
||||||
|
self.context["ytick.left"] = self.ytick_left
|
||||||
|
self.context["ytick.right"] = self.ytick_right
|
||||||
|
self.context["ytick.labelleft"] = self.ytick_labelleft
|
||||||
|
self.context["ytick.labelright"] = self.ytick_labelright
|
||||||
|
self.context["ytick.major.size"] = self.ytick_major_size
|
||||||
|
self.context["ytick.minor.size"] = self.ytick_minor_size
|
||||||
|
self.context["ytick.major.width"] = self.ytick_major_width
|
||||||
|
self.context["ytick.minor.width"] = self.ytick_minor_width
|
||||||
|
self.context["ytick.major.pad"] = self.ytick_major_pad
|
||||||
|
self.context["ytick.minor.pad"] = self.ytick_minor_pad
|
||||||
|
self.context["ytick.color"] = self.ytick_color
|
||||||
|
self.context["ytick.labelcolor"] = self.ytick_labelcolor
|
||||||
|
self.context["ytick.labelsize"] = self.ytick_labelsize
|
||||||
|
self.context["ytick.direction"] = self.ytick_direction
|
||||||
|
self.context["ytick.minor.visible"] = self.ytick_minor_visible
|
||||||
|
self.context["ytick.major.left"] = self.ytick_major_left
|
||||||
|
self.context["ytick.major.right"] = self.ytick_major_right
|
||||||
|
self.context["ytick.minor.left"] = self.ytick_minor_left
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
from mpl_toolkits.mplot3d import axes3d
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
rc = ManchotRC()
|
rc = ManchotRC()
|
||||||
|
|
||||||
with plt.style.context(rc.context):
|
with plt.style.context(rc.context):
|
||||||
fig, axs = plt.subplots(1, 3)
|
fig, axs = plt.subplots(1, 3, layout="constrained")
|
||||||
|
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], [2,1,4,3,6])
|
||||||
axs[0].plot([0,1,2,3,4], [4,3,1,2,4], "--")
|
axs[0].plot([0,1,2,3,4], [4,3,1,2,4], "o--")
|
||||||
|
|
||||||
axs[0].set_title("Lorem")
|
axs[0].set_title("Lorem")
|
||||||
axs[0].set_xlabel("$x~\\mathrm{[cm]}$")
|
axs[0].set_xlabel("$x~\\mathrm{[cm]}$")
|
||||||
@@ -418,5 +554,23 @@ if __name__ == "__main__":
|
|||||||
[2,6,5,6,6,4,5,6,7,5,4,5,2]])
|
[2,6,5,6,6,4,5,6,7,5,4,5,2]])
|
||||||
axs[2].set_xlabel("Value")
|
axs[2].set_xlabel("Value")
|
||||||
axs[2].set_ylabel("Number")
|
axs[2].set_ylabel("Number")
|
||||||
fig.tight_layout() # NOTE: Temporary
|
|
||||||
|
fig = plt.figure()
|
||||||
|
ax = fig.add_subplot(projection="3d")
|
||||||
|
|
||||||
|
X, Y, Z = axes3d.get_test_data(0.05)
|
||||||
|
|
||||||
|
# Plot the 3D surface
|
||||||
|
ax.plot_surface(X, Y, Z, edgecolor='C0', lw=0.5, rstride=8, cstride=8,
|
||||||
|
alpha=0.3)
|
||||||
|
|
||||||
|
# Plot projections of the contours for each dimension. By choosing offsets
|
||||||
|
# that match the appropriate axes limits, the projected contours will sit on
|
||||||
|
# the 'walls' of the graph.
|
||||||
|
ax.contour(X, Y, Z, zdir='z', offset=-100)
|
||||||
|
ax.contour(X, Y, Z, zdir='x', offset=-40)
|
||||||
|
ax.contour(X, Y, Z, zdir='y', offset=40)
|
||||||
|
|
||||||
|
ax.set(xlim=(-40, 40), ylim=(-40, 40), zlim=(-100, 100),
|
||||||
|
xlabel='X', ylabel='Y', zlabel='Z')
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|||||||
Reference in New Issue
Block a user