ImageOptions(dpi=100)
Source¶
Settings of a PNG image of a Plot, used by Plot.save.
The format of an image always comes from the extension of its path. SVG and PDF images are drawn with lines and texts, so they have no resolution and refuse these options.
Added in version 0.1.0
Parameters:
-
dpi(int, default:100)The number of pixels per inch of the image, 100 by default. It only changes the sharpness: a Plot of 6.4 by 4.8 inches gives 640 by 480 pixels at 100, and 1280 by 960 pixels at 200.
Raises:
-
InvalidTypeErrorWhen a setting is not of the type its annotation names.
-
InvalidResolutionErrorWhen
dpiis lower than 1.
Examples:
import tempfile
from pathlib import Path
from matplotlib.image import imread
import numdaplot as ndp
path = Path(tempfile.mkdtemp()) / "prices.png"
prices = ndp.Array.from_list([12.0, 15.5, 14.0, 17.0])
plot = ndp.Plot.line(prices)
plot.save(path, ndp.ImageOptions(dpi=200))
imread(path).shape
# (960, 1280, 4)