Export View as Image
There are two ways to export a scatter plot as an image. You can either download it as a PNG or save it to the widget's view_data
property.
INFO
Image exports follow WYSIWYG, meaning that the exported image will have the exact same size and viewport as the widget. Hence, if you want to export a higher resolution image you have to increase the scatter's width and height. See custom PNG export on how to easily adjust the export resolution.
Export as PNG
To download the current scatter plot view as a PNG click on the download icon.
For instance, given the following scatter.
import jscatter
import numpy as np
x = np.random.normal(0, 0.1, 1000)
y = np.random.normal(0, 0.1, 1000)
scatter = jscatter.Scatter(x, y)
scatter.show()
The downloaded image will look as follows:
INFO
By default, the background color of the image is the same as scatter.widget.background_color
. However, you can also download the view with a transparent background by holding down Alt while clicking on the camera button.
Customize PNG Export
To better control the resolution of the exported PNG, enter the full-screen mode (via the widget button on the left) and open up the resize panel (via the up arrow button in the bottom-left corner). This panel allows you to easily customize the width/height of the scatter plot and offers the ability to up-scale the exported image.
INFO
Note, the exported image is subject to your device pixel ratio, which cannot be changed. This means that if your plot is 100 by 100 pixels in size and your display has a pixel ratio of 2
, the exported PNG is going to be 200 by 200 pixels.
Export to widget.view_data
When you click on the camera icon, the current view will be exported and saved to the widget's view_data
property. You can use that property to print the image or manipulate it in some way if you like.
For instance, given the following scatter.
import jscatter
import numpy as np
x = np.random.rand(500)
y = np.random.rand(500)
scatter = jscatter.Scatter(x, y)
scatter.show()
After having clicked on the camera icon button on the left of the plot, you can access the exported image via scatter.widget.view_data
and, for instance, plot it with Matplotlib as follows:
from matplotlib import pyplot as plt
plt.imshow(scatter.widget.view_data, interpolation='nearest')
plt.show()