How to change the image size for seaborn.objects
Asked Answered
M

1

4

The solutions shown in How to change the figure size of a seaborn axes or figure level plot do not work for seaborn.objects. This question is about the new interface added in seaborn v0.12.

Tried different ways to set the plotted image size but no one worked, below is the code, how to set the below image height and width by pixel or inch?

About seaborn.objects.Plot.add:

import pandas as pd
from seaborn import objects as so

df = sns.load_dataset('planets')
p = so.Plot(data=df, x='orbital_period', y='mass').add(so.Dot())
p.save('output.png')
p.show()

enter image description here

Monazite answered 5/11, 2022 at 10:18 Comment(0)
B
9

With Plot.layout:

(
    so.Plot(data=d, x="point_x", y="point_y")
    .add(so.Dot())
    .layout(size=(w, h))  # in inches * (dpi / 100)
    .save("output.png", dpi=dpi)  # e.g. dpi=100
    .show()
)
Bilodeau answered 5/11, 2022 at 13:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.