@@ -45,6 +45,26 @@ class MPLPlotter(Plotter):
4545 def __init__ (self , figure : Figure , data_provider : DataProvider ):
4646 super ().__init__ (figure , data_provider )
4747
48+ @staticmethod
49+ def _error_column_for_plot_type_data (plot_type_data : str ) -> Optional [str ]:
50+ """Translate PEtab plotTypeData value to column name of internal
51+ data representation
52+
53+ Parameters
54+ ----------
55+ plot_type_data: PEtab plotTypeData value
56+ Returns
57+ -------
58+ Name of corresponding column
59+ """
60+ if plot_type_data == MEAN_AND_SD :
61+ return 'sd'
62+ if plot_type_data == MEAN_AND_SEM :
63+ return 'sem'
64+ if plot_type_data == PROVIDED :
65+ return 'noise_model'
66+ return None
67+
4868 def generate_lineplot (self , ax : 'matplotlib.pyplot.Axes' ,
4969 dataplot : DataPlot ,
5070 plotTypeData : str ) -> None :
@@ -67,14 +87,7 @@ def generate_lineplot(self, ax: 'matplotlib.pyplot.Axes',
6787 measurements_to_plot , simulations_to_plot = \
6888 self .data_provider .get_data_to_plot (dataplot ,
6989 plotTypeData == PROVIDED )
70- noise_col = None
71- # set type of noise
72- if plotTypeData == MEAN_AND_SD :
73- noise_col = 'sd'
74- elif plotTypeData == MEAN_AND_SEM :
75- noise_col = 'sem'
76- elif plotTypeData == PROVIDED :
77- noise_col = 'noise_model'
90+ noise_col = self ._error_column_for_plot_type_data (plotTypeData )
7891
7992 label_base = dataplot .legendEntry
8093
@@ -155,14 +168,7 @@ def generate_barplot(self, ax: 'matplotlib.pyplot.Axes',
155168 Specifies how replicates should be handled.
156169 """
157170 # TODO: plotTypeData == REPLICATE?
158- # set type of noise
159- noise_col = None
160- if plotTypeData == MEAN_AND_SD :
161- noise_col = 'sd'
162- elif plotTypeData == MEAN_AND_SEM :
163- noise_col = 'sem'
164- elif plotTypeData == PROVIDED :
165- noise_col = 'noise_model'
171+ noise_col = self ._error_column_for_plot_type_data (plotTypeData )
166172
167173 simu_colors = None
168174 measurements_to_plot , simulations_to_plot = \
@@ -222,7 +228,7 @@ def generate_scatterplot(self, ax: 'matplotlib.pyplot.Axes',
222228 ax .scatter (measurements_to_plot .data_to_plot ['mean' ],
223229 simulations_to_plot .data_to_plot ['mean' ],
224230 label = getattr (dataplot , LEGEND_ENTRY ))
225- ax = self ._square_plot_equal_ranges (ax )
231+ self ._square_plot_equal_ranges (ax )
226232
227233 def generate_subplot (self ,
228234 ax ,
@@ -278,11 +284,10 @@ def generate_subplot(self,
278284 elif subplot .xScale == 'order' :
279285 ax .set_xscale ("linear" )
280286 # check if conditions are monotone decreasing or increasing
281- if np .all (
282- np .diff (subplot .conditions ) < 0 ): # monot. decreasing
283- xlabel = subplot .conditions [::- 1 ] # reversing
284- conditions = range (len (subplot .conditions ))[
285- ::- 1 ] # reversing
287+ if np .all (np .diff (subplot .conditions ) < 0 ):
288+ # monot. decreasing -> reverse
289+ xlabel = subplot .conditions [::- 1 ]
290+ conditions = range (len (subplot .conditions ))[::- 1 ]
286291 ax .set_xticks (range (len (conditions )), xlabel )
287292 elif np .all (np .diff (subplot .conditions ) > 0 ):
288293 xlabel = subplot .conditions
@@ -305,21 +310,18 @@ def ticks(y, _):
305310 if subplot .yScale == LOG :
306311 ax .yaxis .set_major_formatter (mtick .FuncFormatter (ticks ))
307312
308- if not subplot .plotTypeSimulation = = BAR_PLOT :
313+ if subplot .plotTypeSimulation ! = BAR_PLOT :
309314 ax .legend ()
310315 ax .set_title (subplot .plotName )
311- ax .relim ()
312316 if subplot .xlim :
313317 ax .set_xlim (subplot .xlim )
314318 if subplot .ylim :
315319 ax .set_ylim (subplot .ylim )
316320 ax .autoscale_view ()
317321
318322 # Beautify plots
319- ax .set_xlabel (
320- subplot .xLabel )
321- ax .set_ylabel (
322- subplot .yLabel )
323+ ax .set_xlabel (subplot .xLabel )
324+ ax .set_ylabel (subplot .yLabel )
323325
324326 def generate_figure (
325327 self ,
0 commit comments