Lines using XYBlockRenderer

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
kimba516
Posts: 4
Joined: Mon May 19, 2008 11:52 pm

Lines using XYBlockRenderer

Post by kimba516 » Wed Jun 04, 2008 7:50 pm

Hello! I've created a spectral plot using XYBlockRenderer, but I think there's some default to have lines show up on the chart as markers to better locate points on the graph. It's a bit much though, so I was wondering is there was a way to turn these lines off? What's interesting is that the lines vary with the size of the chart, and if the chart is small they aren't visible. I saw this issue in another topic, but didn't quite understand how to fix the problem.

Larger chart:
Image

Small chart:
Image

Here's a sample of my code to create the chart...

Code: Select all

public JFreeChart createChart(XYZDataset dataset) {
        NumberAxis xAxis = new NumberAxis("Theta");
        xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        xAxis.setLowerMargin(0.0);
        xAxis.setUpperMargin(0.0);
        xAxis.setAxisLinePaint(Color.white);
        xAxis.setTickMarkPaint(Color.white);

        NumberAxis yAxis = new NumberAxis("Phi");
        yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        yAxis.setLowerMargin(0.0);
        yAxis.setUpperMargin(0.0);
        yAxis.setAxisLinePaint(Color.white);
        yAxis.setTickMarkPaint(Color.white);

        XYBlockRenderer renderer = new XYBlockRenderer();
        LookupPaintScale paintScale = new LookupPaintScale(min, max,
                Color.gray);
	//code adding paints to paintScale
        renderer.setPaintScale(paintScale);

        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
        plot.setBackgroundPaint(Color.lightGray);
        //plot.setDomainGridlinesVisible(false);
        plot.setRangeGridlinePaint(Color.white);
        plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
        plot.setOutlinePaint(Color.blue);
        JFreeChart chart = new JFreeChart(patternType.toUpperCase(), plot);
        chart.removeLegend();
        NumberAxis scaleAxis = new NumberAxis("Scale");
        scaleAxis.setAxisLinePaint(Color.white);
        scaleAxis.setTickMarkPaint(Color.white);
        scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 7));
        scaleAxis.setRange(min, max);
        PaintScaleLegend legend = new PaintScaleLegend(paintScale,
                scaleAxis);
        legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
        legend.setAxisOffset(5.0);
        legend.setMargin(new RectangleInsets(5, 5, 5, 5));
        legend.setFrame(new BlockBorder(Color.red));
        legend.setPadding(new RectangleInsets(10, 10, 10, 10));
        legend.setStripWidth(10);
        legend.setPosition(RectangleEdge.RIGHT);
        legend.setBackgroundPaint(new Color(120, 120, 180));
        chart.addSubtitle(legend);
        chart.setBackgroundPaint(new Color(180, 180, 250));
        return chart;
    }
Thanks for any guidance!

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Wed Jun 04, 2008 7:56 pm

You probably want to adjust the block height and width settings in the renderer. The default value is 1.0 for each...looking at the way your data is spaced, you probably want 2.0 (so just call renderer.setBlockHeight(2.0) and renderer.setBlockWidth(2.0)).
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

s!nker
Posts: 1
Joined: Wed Jul 19, 2017 12:45 am
antibot: No, of course not.

Re: Lines using XYBlockRenderer

Post by s!nker » Wed Jul 19, 2017 12:52 am

Hello! Could you tell me how possible to create Plot like this http://www.jfree.org/phpBB2/viewtopic.p ... 814#p70173
I need code example, because I can't find info about color model for class in JFreeChart...

Locked