Plotnine in Databricks

160 views Asked by At

I am using Databricks, and when trying to display a plot made with plotnine, every time I run any cell, the plot appears on the output multiple times. My code is the next one:

my_plot = (ggplot(df, aes(x='x', y='y') + 
  geom_col(show_legend=True) +
  scale_x_discrete(name='Familia') +
  scale_y_continuous(name='Número de prendas', 
                     breaks=range(0,  8000+1, 2000)) +
  ggtitle('Número de prendas por familia') +
  theme(figure_size=(8,6), 
        panel_grid_major_y=element_line(color='000', size=0.3, linetype='solid'),
        panel_grid_minor_y=element_line(color='000', size=0.2, linetype='dashed'))
  )

To display the result, I've tried the next 2 options:

  1. my_plot.draw()
  2. my_plot

When I execute the first one, appears only one time, but if I do any change in the code of the plot, the changes doesn't appear.

0

There are 0 answers