Plotting gridlines from Y2 (Secondary) axis

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Choudhary Akshay

Plotting gridlines from Y2 (Secondary) axis

Post by Choudhary Akshay » Wed Sep 15, 2004 2:25 pm

I am able to draw gridlines only for the ticks on the primary axis. However i want to draw gridlines for both primary and secondary axises.
Here is my code:

Code:

final JFreeChart chart = ChartFactory.createXYLineChart(
footer, // chart title
"E'/E'' (Pa)", // domain axis label
xaxis, // range axis label
dataset, // data
PlotOrientation.VERTICAL,
false, // include legend
true,
false
);

final XYPlot plot = chart.getXYPlot();
final NumberAxis domainAxis = new NumberAxis(xaxis);
final LogarithmicAxis rangeAxis = new LogarithmicAxis("E'/E'' (Pa)");
final LogarithmicAxis rangeAxisY2 = new LogarithmicAxis("Tan Delta");

final XYSeriesCollection dataset2 = createDataset(2);
plot.setDataset(3, dataset2);
plot.mapDatasetToRangeAxis(3,3);
plot.setRangeAxis(3,rangeAxisY2);
plot.setRangeAxisLocation(3,AxisLocation.BOTTOM_OR_RIGHT);

plot.setDomainAxis(domainAxis);
plot.setRangeAxis(rangeAxis);

chart.setBackgroundPaint(Color.white);

Ayilay
Posts: 2
Joined: Mon Sep 10, 2018 8:16 pm
antibot: No, of course not.

Re: Plotting gridlines from Y2 (Secondary) axis

Post by Ayilay » Mon Sep 10, 2018 8:17 pm

Has anyone solved this? I also wish to plot gridlines for my secondary Y axis and have not found a suitable solution on the internet

Locked