How to remove the background's pattern?

删除回忆录丶 提交于 2019-12-11 11:08:36

问题


I'm sorry I don't know what it is so I may have asked an unclear question but I hope the attached images explains it. I circled the areas I need to remove. I simply need the whole background to have one continuous color whether it's gray or anything else.

Here is the piece of code I use to generate the chart:

final JFreeChart chart = ChartFactory.createTimeSeriesChart(generateTitle(title, resultsCount), xAxis, yAxis,
                (XYDataset) paramCategoryDataset, true, false, false);
  final XYPlot plot = chart.getXYPlot();
  plot.setNoDataMessage(MSG_NO_DATA);
  plot.setBackgroundPaint(Color.LIGHT_GRAY); //I need the BG to be plain gray.

  SymbolAxis localSymbolAxis1 = new SymbolAxis("Domain", new String[] { "Failure", "Success", "Failure", "Success", "Failure", "Success" });
  plot.setRangeAxis(localSymbolAxis1);
  XYStepRenderer localXYStepRenderer = new XYStepRenderer();
  localXYStepRenderer.setBaseFillPaint(Color.white);
  localXYStepRenderer.setUseFillPaint(true);
  localXYStepRenderer.setBaseShape(ShapeUtilities.createDiamond(2f));
  localXYStepRenderer.setAutoPopulateSeriesShape(false);
  localXYStepRenderer.setAutoPopulateSeriesStroke(false);
  localXYStepRenderer.setDataBoundsIncludesVisibleSeriesOnly(false);
  plot.setRenderer(localXYStepRenderer);

And here is the image showing what I need to remove within in curved rectangles:

But let me ask another greedy question. Is there a way to have my step graph line right in one of those hilighted areas instead of having half of it in the dark part and the other half in the lighter part ?


回答1:


To get a continuous background color, you can set the gridlines' visibility to false.

plot.setDomainGridlinesVisible(false);
plot.setRangeGridlinesVisible(false);

Alternatively, you can set the plot's background color to match the gridlines.

Addendum: I meant the light and dark areas in the background.

Ah, you want the alternating light- and medium-gray areas to be a single shade of gray. Try this:

symbolAxis.setGridBandsVisible(false);


来源:https://stackoverflow.com/questions/11484613/how-to-remove-the-backgrounds-pattern

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!