Scatter plot using the Gral library
Code: "gral_plotXY.py". Programming language: Python
DMelt Version 1.7. Last modified: 02/27/1971. License: Pro
https://datamelt.org/code/cache/gral_plotXY_6416.py
To run this script using the DMelt IDE,
copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.
from de.erichseifert.gral.data import DataTable
from de.erichseifert.gral.plots import XYPlot
from de.erichseifert.gral.ui import InteractivePanel
from de.erichseifert.gral.graphics import Insets2D;
from java.util import *
from java.lang import *
from java.awt import *
from javax.swing import *
r=Random()
# specify Java types
data1 = DataTable([Double,Double]);
for i in range(200):
data1.add([Double(r.nextGaussian()*2.0), Double(r.nextGaussian()*2.0)])
data2=DataTable([Double,Double]);
for i in range(500):
data2.add([Double(r.nextGaussian()), Double(r.nextGaussian())])
# Create a new xy-plot
plot = XYPlot([data1,data2])
# plot.setLegendVisible(True)
# format
plot.setInsets(Insets2D.Double(20.0, 40.0, 40.0, 40.0));
plot.getTitle().setText("Test");
# Format points
plot.getPointRenderers(data1).get(0).setColor(Color.red);
plot.getPointRenderers(data2).get(0).setColor(Color.blue);
# use Java
fr=JFrame()
fr.setSize(600, 400)
fr.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
fr.add(InteractivePanel(plot), BorderLayout.CENTER);
fr.setVisible(True)
You see the box below because you did not login.