I am encountering multiple issues when trying to display data generated by my Jython script. First, the style argument Plot.CROSS
is ignored when using the following code, resulting in an unreadable line plot.:
p1=Plot("title","x","y", array1, array2, Plot.CROSS)
p1.show()
Second, this method glimpsed on a Java page doesn't return an error, but the plot does not display (empty plot, from -Inf to +Inf).
p2 = Plot("title","x","y")
p2.addPoints(array1,array2, Plot.CROSS)
p2.show()
Also, what is the correct format for changing the colour used? I have tried the p1.setColor(Color.RED)
approach, but is comes back as undefined name.
I have some experience with Python, but none with Java. If anyone knows a handy reference for learning ImageJ scripting, I would appreciate it.
In your second example, you are missing to set the plot limits using setLimits()
. The following example script creates a plot with three points marked by red crosses:
from jarray import array
from java.awt import Color
from ij.gui import Plot
xArr = array([0.9, 2.0, 3.14], 'd')
yArr = array([2.3, 2.0, 13.14], 'd')
plot = Plot("Title", "X", "Y")
plot.setLimits(0.0, 5.0, 0.0, 20.0)
plot.setColor(Color.RED)
plot.addPoints(xArr,yArr, Plot.CROSS)
plot.show()
See the javadoc of the ij.gui.Plot
class for the available functions.
For documentation about ImageJ scripting, see the following resources:
For advanced plotting in ImageJ, you might also want to look at the JFreeChart library that ships with Fiji and is used by some of its plugins.