hello, im trying to draw an ichimoku cloud.
http://www.swing-trade-stocks.com/image ... charts.png
so, how do i colour an area between 2 lines? thanks.
how to colour area between 2 lines?
-
- Posts: 11
- Joined: Tue Feb 22, 2011 8:15 pm
- antibot: No, of course not.
Re: how to colour area between 2 lines?
This would be very interesting for me as well. A typical application would be to plot a line with a line above and under showing how a graph develops +- one standard deviation. Fill the space between the upper and lower line with a fill color and voila, it looks quite nice. No clue as to how one actually should do this though ...
I can guess that one way would be to plot three graphs/pictures and then overlay them ontop of eachother somehow.
I can guess that one way would be to plot three graphs/pictures and then overlay them ontop of eachother somehow.
-
- Posts: 1
- Joined: Fri Sep 14, 2012 6:57 pm
- antibot: No, of course not.
Re: how to colour area between 2 lines?
The Ichimoku Cloud can be drawn using XYDifferenceRenderer. The code goes like this:
Note that by default when Senkou Span A is above Senkou Span B, then the color of the cloud would be green; when Senkou Span A is below Senkou Span B, then the color of the cloud is red. To change the color of the cloud, use XYDifferenceRenderer.setPositivePaint and XYDifferenceRenderer.setNegativePaint.
Code: Select all
/**
* Adds plot of Kumo to an existing plot
* @param plot an already created and initialized plot object, we will add Kumo to this plot
* @param tsSenkouSpanA time series of "Leading Span A", which forms one edge of the cloud
* @param tsSenkouSpanB time series of "Leading Span B", which forms the other edge of the cloud
8?
void drawKumo(XYPlot plot, TimeSeries tsSenkouSpanA, TimeSeries tsSenkouSpanB) {
TimeSeriesCollection tsc = new TimeSeriesCollection();
tsc.addSeries(tsSenkouSpanA);
tsc.addSeries(tsSenkouSpanB);
XYDifferenceRenderer xydr = new XYDifferenceRenderer();
// Here I assume that "plot" does not have any other plots yet. Hence the following two lines are setting the data set
// an the renderer for the 1st (zeroeth, as in zero-based systems) time series collection to be plotted.
plot.setDataSet(0, tsc);
plot.setRenderer(0, xydr);
}
Re: how to colour area between 2 lines?
As to what I was talking about, some code can be found here:
http://www.jfree.org/phpBB2/viewtopic.p ... 31#p167479
http://www.jfree.org/phpBB2/viewtopic.p ... 31#p167479