3131#warnings.simplefilter('ignore', SettingWithCopyWarning)
3232warnings .simplefilter ('ignore' )
3333
34- __version__ = "0.6.4 "
34+ __version__ = "0.6.5 "
3535_basefigure = plt .figure (figsize = (1 ,1 ))
3636_render = _basefigure .canvas .get_renderer ()
3737_scale = Affine2D ().scale (1. / _basefigure .dpi )
@@ -244,7 +244,7 @@ def draw_labels(bricks, gori, gcp, figsize):
244244 pad_x = 4
245245 else :
246246 if StrictVersion (plotnine_version ) >= StrictVersion ("0.12" ):
247- pad_x = 14 + (get_property ('axis_text_x' , 'size' ) - 11 ) * 0.5 + (get_property ('axis_title_x' , 'size' ) - 11 ) * 0.5
247+ pad_x = 16 + (get_property ('axis_text_x' , 'size' ) - 11 ) * 0.5 + (get_property ('axis_title_x' , 'size' ) - 11 ) * 0.5
248248 else :
249249 pad_x = margin .get_as ('t' , 'pt' )
250250
@@ -254,7 +254,7 @@ def draw_labels(bricks, gori, gcp, figsize):
254254 pad_y = 4
255255 else :
256256 if StrictVersion (plotnine_version ) >= StrictVersion ("0.12" ):
257- pad_y = 12 + (get_property ('axis_text_y' , 'size' ) - 11 ) * 0.5 + (get_property ('axis_title_y' , 'size' ) - 11 ) * 0.5
257+ pad_y = 13 + (get_property ('axis_text_y' , 'size' ) - 11 ) * 0.5 + (get_property ('axis_title_y' , 'size' ) - 11 ) * 0.5
258258 else :
259259 pad_y = margin .get_as ('r' , 'pt' )
260260
@@ -339,21 +339,36 @@ def draw_labels(bricks, gori, gcp, figsize):
339339
340340 def draw_legend (bricks , gori , gcp , figsize ):
341341 get_property = gcp .theme .themeables .property
342- legend_box = gcp .guides .build (gcp )
343- if StrictVersion (plotnine_version ) >= StrictVersion ("0.12" ):
342+ #print(get_property)
343+ if StrictVersion (plotnine_version ) >= StrictVersion ("0.13" ):
344+ legend = gcp .guides ._build ()
345+ if len (legend ) == 0 :
346+ return None
347+ legend_box = legend [0 ].draw ()
348+ gcp .guides ._apply_guide_themes (legend )
349+ wratio = 1
350+ hratio = 1
351+ elif StrictVersion (plotnine_version ) >= StrictVersion ("0.12" ):
352+ legend_box = gcp .guides .build (gcp )
344353 wratio = 1
345354 hratio = 1
346355 else :
356+ legend_box = gcp .guides .build (gcp )
347357 wratio = figsize [0 ]
348358 hratio = figsize [1 ]
349359
360+ #print(legend_box, dir(legend_box[0]))
350361 try :
351362 spacing = get_property ('legend_box_spacing' )
352363 except KeyError :
353364 spacing = 0.1
354365
366+ if StrictVersion (plotnine_version ) >= StrictVersion ("0.13" ):
367+ spacing = gcp .theme .getp ('legend_box_spacing' )
368+ position = gcp .theme .getp ("legend_position" )
369+ else :
370+ position = gcp .guides .position
355371
356- position = gcp .guides .position
357372 if position == 'right' :
358373 loc = 6
359374 x = 1.0 + spacing / wratio
@@ -398,7 +413,17 @@ def draw_legend(bricks, gori, gcp, figsize):
398413 bricks ._ggplot_legend_loc = loc
399414 bricks ._ggplot_legend_x = x
400415 bricks ._ggplot_legend_y = y
401- if StrictVersion (plotnine_version ) >= StrictVersion ("0.12" ):
416+ if StrictVersion (plotnine_version ) >= StrictVersion ("0.13" ):
417+ #from plotnine.themes.theme import themeable, theme_update
418+ #gori.theme.themeables['legend_background'] = themeable.from_class_name('legend_background', anchored_box)
419+ for key in gori .theme .themeables :
420+ if "legend" in key :
421+ #print(gori.theme.themeables[key])
422+ gori .theme .themeables [key ].apply_figure (gori .figure , gori .theme .targets )
423+ for ax in gori .axs :
424+ gori .theme .themeables [key ].apply_ax (ax )
425+
426+ elif StrictVersion (plotnine_version ) >= StrictVersion ("0.12" ):
402427 gori .theme ._targets ['legend_background' ] = anchored_box
403428 for key in gori .theme .themeables :
404429 if "legend" in key :
@@ -564,7 +589,14 @@ def draw_title(bricks, gori, gcp, figsize):
564589 ggplot .facet .strips .generate ()
565590
566591 for i in range (len (ggplot .facet .strips )):
567- if StrictVersion (plotnine_version ) >= StrictVersion ("0.12" ):
592+ if StrictVersion (plotnine_version ) >= StrictVersion ("0.13" ):
593+ ggplot .facet .strips [i ].label_info = strips [i ].label_info
594+ ggplot .facet .strips [i ].layout_info = strips [i ].layout_info
595+ ggplot .facet .strips [i ].theme = strips [i ].theme
596+ ggplot .facet .strips [i ].position = strips [i ].position
597+ ggplot .facet .strips [i ].figure = ggplot .facet .strips [i ].ax
598+
599+ elif StrictVersion (plotnine_version ) >= StrictVersion ("0.12" ):
568600 ggplot .facet .strips [i ].position = strips [i ].draw_info .position
569601 ggplot .facet .strips [i ].draw_info .box_height = strips [i ].draw_info .box_height
570602 ggplot .facet .strips [i ].draw_info .box_width = strips [i ].draw_info .box_width
@@ -598,6 +630,7 @@ def draw_title(bricks, gori, gcp, figsize):
598630 if StrictVersion (plotnine_version ) >= StrictVersion ("0.13" ):
599631 ggplot ._draw_panel_borders ()
600632 ggplot .facet .theme = ggplot .theme
633+
601634 ggplot ._draw_breaks_and_labels ()
602635 ggplot ._draw_watermarks ()
603636 new = themeable .from_class_name
@@ -631,6 +664,7 @@ def draw_title(bricks, gori, gcp, figsize):
631664
632665 if StrictVersion (plotnine_version ) >= StrictVersion ("0.9" ):
633666 xl , yl = draw_labels (ax , ggplot , gcp , figsize )
667+
634668 draw_legend (ax , ggplot , gcp , figsize ) #0.13 makes Erros here.
635669 draw_title (ax , ggplot , gcp , figsize )
636670
0 commit comments