plot_utils: fix setting the size of the plots
Longstanding bug, finally fixed. Merge set_plot_size() into
pre_plot_setup() in the process as it's the only thing that it does.
diff --git a/cr2/plot_utils.py b/cr2/plot_utils.py
index 092ec8e..a9fa9da 100644
--- a/cr2/plot_utils.py
+++ b/cr2/plot_utils.py
@@ -5,23 +5,6 @@
GOLDEN_RATIO = 1.618034
-def set_plot_size(width, height):
- """Set the plot size.
-
- This has to be called before calls to .plot()
- """
- if height is None:
- if width is None:
- height = 6
- width = 10
- else:
- height = width / GOLDEN_RATIO
- else:
- if width is None:
- width = height * GOLDEN_RATIO
-
- plt.figure(figsize=(width, height))
-
def normalize_title(title, opt_title):
"""
Return a string with that contains the title and opt_title if it's not the empty string
@@ -70,13 +53,22 @@
def pre_plot_setup(width=None, height=None):
"""initialize a figure
- width and height are numbers This function should be called before
- any calls to plot()
+ width and height are numbers. This function should be called
+ before any calls to plot()
+
"""
- set_plot_size(width, height)
+ if height is None:
+ if width is None:
+ height = 6
+ width = 10
+ else:
+ height = width / GOLDEN_RATIO
+ else:
+ if width is None:
+ width = height * GOLDEN_RATIO
- _, ax = plt.subplots()
+ _, ax = plt.subplots(figsize=(width, height))
return ax