Saving high-resolution images with plotnine

I'm trying to use plotnine to save a high-resolution png image.

With a test dataset, this looks like:

from plotnine import *
import pandas as pd
import numpy as np

df = pd.DataFrame()
df['x'] = np.arange(0,10,0.01)
df['y'] = np.sin(df['x'])

p = ggplot(df, aes(x='x',y='y')) + labs(x='x', y='y') + geom_point(size=0.1)
p.save(filename = 'test3.png', height=5, width=5, units = 'in', dpi=1000)

This produces a low-resolution .png file containing my plot, which is not improved when I increase the specified dpi.

I've also tried saving with:

ggsave(plot=p, filename='test.png', dpi=1000)

and replacing dpi=1000 with res=1000. This produces identical low-resolution png files.

How can I save my plot at the resolution I want?

Edit: This bug is resolved in plotnine version 0.3.0. and the above code works correctly.


Since this still isn't answered and I just got directed here, too...

According to @has2k1 (the author of plotnine), this was a bug and is now resolved. This commit looks like it might be the referenced fix.

To solve the issue, ensure you are using the git version or at least version 0.3.0.