mirror of
https://codeberg.org/Yael-II/Matplotlib-Style.git
synced 2026-03-15 05:46:26 +01:00
2025-11-21: Started manchot_plot default rc parameters
This commit is contained in:
@@ -28,6 +28,77 @@ GNU General Public License for more details.
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see www.gnu.org/licenses/.
|
along with this program. If not, see www.gnu.org/licenses/.
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
|
|
||||||
def ping():
|
import matplotlib as mpl
|
||||||
return "pong"
|
import numpy as np
|
||||||
|
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
from cycler import cycler
|
||||||
|
|
||||||
|
cm = 0.3937 # in/cm
|
||||||
|
|
||||||
|
class ManchotRC:
|
||||||
|
def __init__(self):
|
||||||
|
self.context = {}
|
||||||
|
|
||||||
|
# Paper
|
||||||
|
self.paper = (21*cm, 29.7*cm)
|
||||||
|
self.margin_left = 3*cm
|
||||||
|
self.margin_right = 3*cm
|
||||||
|
self.margin_cols = 0*cm
|
||||||
|
self.n_cols = 1
|
||||||
|
self.aspect = 3/2
|
||||||
|
|
||||||
|
# Figure
|
||||||
|
self.figure_dpi = 150
|
||||||
|
self.savefig_dpi = 300
|
||||||
|
|
||||||
|
# Font
|
||||||
|
self.font_family = "serif"
|
||||||
|
self.font_serif = "Latin Modern Roman"
|
||||||
|
self.font_size = 10
|
||||||
|
|
||||||
|
# Text / LaTeX
|
||||||
|
self.text_usetex = True
|
||||||
|
self.latex_preamble = ""
|
||||||
|
|
||||||
|
# Compute
|
||||||
|
self._compute()
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _compute(self):
|
||||||
|
# Paper
|
||||||
|
margin = self.margin_left + self.margin_right \
|
||||||
|
+ (self.n_cols - 1) * self.margin_cols
|
||||||
|
figsize_x = self.paper[0]/self.n_cols - margin
|
||||||
|
figsize_y = figsize_x / self.aspect
|
||||||
|
|
||||||
|
# Figure
|
||||||
|
self.context["figure.figsize"] = (figsize_x, figsize_y)
|
||||||
|
self.context["figure.dpi"] = self.figure_dpi
|
||||||
|
self.context["savefig.dpi"] = self.savefig_dpi
|
||||||
|
|
||||||
|
# Font
|
||||||
|
self.context["font.family"] = self.font_family
|
||||||
|
self.context["font.serif"] = self.font_serif
|
||||||
|
self.context["font.size"] = self.font_size
|
||||||
|
|
||||||
|
# Text / LaTeX
|
||||||
|
self.context["text.usetex"] = self.text_usetex
|
||||||
|
self.context["text.latex.preamble"] = self.latex_preamble
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
rc = ManchotRC()
|
||||||
|
|
||||||
|
print(rc.context)
|
||||||
|
|
||||||
|
with plt.style.context(rc.context):
|
||||||
|
fig, ax = plt.subplots(1)
|
||||||
|
ax.plot([0,1,2,3,4], [2,1,4,3,6])
|
||||||
|
ax.set_xlabel("$x\\ \\mathrm{[cm]}$")
|
||||||
|
ax.set_ylabel("$y\\ \\mathrm{[cm]}$")
|
||||||
|
plt.show()
|
||||||
|
|||||||
Reference in New Issue
Block a user