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.
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.
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()