@@ -77,9 +77,9 @@ def plot_vertical_section_comparison(
77
77
maxXTicks = 20 ,
78
78
calendar = 'gregorian' ,
79
79
compareAsContours = False ,
80
+ comparisonContourLineWidth = None ,
80
81
comparisonContourLineStyle = None ,
81
82
comparisonContourLineColor = None ,
82
- comparisonContourColormap = None ,
83
83
labelContours = False ,
84
84
contourLabelPrecision = 1 ,
85
85
resultSuffix = 'Result' ,
@@ -189,7 +189,7 @@ def plot_vertical_section_comparison(
189
189
the number of dots per inch of the figure, taken from section ``plot``
190
190
option ``dpi`` in the config file by default
191
191
192
- lineWidth : int , optional
192
+ lineWidth : float , optional
193
193
the line width of contour lines (if specified)
194
194
195
195
lineStyle : str, optional
@@ -273,6 +273,10 @@ def plot_vertical_section_comparison(
273
273
refArray is None, in which case only the contours of modelArray will be
274
274
plotted on the single panel plot).
275
275
276
+ comparisonContourLineWidth : float, optional
277
+ the line width of contour lines of the comparisonFieldName field on
278
+ a contour comparison plot
279
+
276
280
comparisonContourLineStyle : str, optional
277
281
the line style of contour lines of the reference field on a contour
278
282
comparison plot
@@ -337,15 +341,15 @@ def plot_vertical_section_comparison(
337
341
# depending on how many x axes are to be displayed on the plots
338
342
if singlePanel :
339
343
if compareAsContours and refArray is not None and \
340
- contourColormap is None and \
341
- comparisonContourColormap is None :
344
+ contourColormap is None :
342
345
# no color bar but there is a legend at the bottom
343
346
if len (xCoords ) == 3 :
344
347
figsize = (8 , 8 )
345
348
else :
346
349
figsize = (8 , 7 )
347
350
else :
348
- figsize = (8 , 5 )
351
+ # color bar and legend
352
+ figsize = (8 , 7 )
349
353
elif len (xCoords ) == 3 :
350
354
figsize = (8 , 17 )
351
355
else :
@@ -436,9 +440,9 @@ def plot_vertical_section_comparison(
436
440
contourComparisonField = contourComparisonField ,
437
441
comparisonFieldName = comparisonFieldName ,
438
442
originalFieldName = originalFieldName ,
443
+ comparisonContourLineWidth = comparisonContourLineWidth ,
439
444
comparisonContourLineStyle = comparisonContourLineStyle ,
440
445
comparisonContourLineColor = comparisonContourLineColor ,
441
- comparisonContourColormap = comparisonContourColormap ,
442
446
labelContours = labelContours ,
443
447
contourLabelPrecision = contourLabelPrecision ,
444
448
maxTitleLength = maxTitleLength )
@@ -585,9 +589,9 @@ def plot_vertical_section(
585
589
contourComparisonField = None ,
586
590
comparisonFieldName = None ,
587
591
originalFieldName = None ,
592
+ comparisonContourLineWidth = None ,
588
593
comparisonContourLineStyle = None ,
589
594
comparisonContourLineColor = None ,
590
- comparisonContourColormap = None ,
591
595
labelContours = False ,
592
596
contourLabelPrecision = 1 ,
593
597
maxTitleLength = 70 ):
@@ -694,7 +698,7 @@ def plot_vertical_section(
694
698
yLim : float array, optional
695
699
y range of plot
696
700
697
- lineWidth : int , optional
701
+ lineWidth : float , optional
698
702
the line width of contour lines (if specified)
699
703
700
704
lineStyle : str, optional
@@ -789,6 +793,10 @@ def plot_vertical_section(
789
793
contours on a contour comparison plot). If contourComparisonField
790
794
is None, this parameter is ignored.
791
795
796
+ comparisonContourLineWidth : float, optional
797
+ the line width of contour lines of the comparisonFieldName field on
798
+ a contour comparison plot
799
+
792
800
comparisonContourLineStyle : str, optional
793
801
the line style of contour lines of the comparisonFieldName field on
794
802
a contour comparison plot
@@ -975,19 +983,26 @@ def plot_vertical_section(
975
983
plt .clabel (cs1 , fmt = fmt_string )
976
984
977
985
if plotAsContours and contourComparisonField is not None :
986
+ if comparisonContourLineWidth is None :
987
+ comparisonContourLineWidth = lineWidth
978
988
cs2 = plt .tricontour (maskedComparisonTriangulation ,
979
989
contourComparisonField .values .ravel (),
980
990
levels = contourLevels ,
981
991
colors = comparisonContourLineColor ,
982
992
linestyles = comparisonContourLineStyle ,
983
- linewidths = lineWidth ,
984
- cmap = comparisonContourColormap )
993
+ linewidths = comparisonContourLineWidth ,
994
+ cmap = contourColormap )
985
995
986
996
if labelContours :
987
997
plt .clabel (cs2 , fmt = fmt_string )
988
998
989
- if plotAsContours and contourComparisonField is not None and \
990
- lineColor is not None and comparisonContourLineColor is not None :
999
+ plotLegend = (((lineColor is not None and
1000
+ comparisonContourLineColor is not None ) or
1001
+ (lineWidth is not None and
1002
+ comparisonContourLineWidth is not None )) and
1003
+ (plotAsContours and contourComparisonField is not None ))
1004
+
1005
+ if plotLegend :
991
1006
h1 , _ = cs1 .legend_elements ()
992
1007
h2 , _ = cs2 .legend_elements ()
993
1008
if labelContours :
@@ -1043,29 +1058,13 @@ def plot_vertical_section(
1043
1058
yearStride = yearStrideXTicks )
1044
1059
1045
1060
if contourLevels is not None :
1046
- if plotAsContours and contourComparisonField is not None and \
1047
- comparisonContourColormap is not None :
1048
- cbar2 = fig .colorbar (cs2 , ax = ax , fraction = .05 ,
1049
- orientation = 'vertical' ,
1050
- spacing = 'proportional' )
1051
- if colorbarLabel is None :
1052
- cbar2 .set_label (comparisonFieldName )
1053
- else :
1054
- cbar2 .set_label (f'{ comparisonFieldName } ({ colorbarLabel } )' )
1055
-
1056
1061
if contourColormap is not None :
1057
1062
cbar1 = fig .colorbar (cs1 , ax = ax , fraction = .05 ,
1058
1063
orientation = 'vertical' ,
1059
1064
spacing = 'proportional' )
1060
1065
1061
- if contourComparisonField is None :
1062
- if colorbarLabel is None :
1063
- cbar1 .set_label (originalFieldName )
1064
- else :
1065
- cbar1 .set_label (f'{ originalFieldName } ({ colorbarLabel } )' )
1066
- else :
1067
- cbar1 .ax .set_yticklabels ([])
1068
- cbar1 .set_label (originalFieldName )
1066
+ if colorbarLabel is not None :
1067
+ cbar1 .set_label (colorbarLabel )
1069
1068
1070
1069
# add a second x-axis scale, if it was requested
1071
1070
if xCoords is not None and len (xCoords ) >= 2 :
0 commit comments