1

I've used the following code to draw a plot using JMathPlot onto a JFrame, however, my plot is too small to make sense.

final Plot2DPanel plot = new Plot2DPanel();
JPanel plotPanel = new JPanel();
plotPanel.add(plot);
frame.add(plotPanel, BorderLayout.EAST);
...
plot.addScatterPlot("Pressure over Flow", XY);

Here is an image:

enter image description here

I want the plot to be reasonable resized so the graph will be readable. How can I do this?

Mehmet K
  • 2,805
  • 1
  • 23
  • 35
  • `plotPanel` is using a `FlowLayout`, try using `BorderLayout` and see if that makes any difference – MadProgrammer Aug 27 '13 at 07:04
  • or you can to override getPreferredSize for Plot2DPanel – mKorbel Aug 27 '13 at 07:44
  • I removed the panel I used, and added the plot to the frame directly, and added it to BorderLayout.CENTER, and it worked! (and I moved what was in the BorderLayout.CENTER before to .WEST. I'm assuming that jswing bases the resizing on the center element, because now resizing the window actually resizes the graph too, unlike before – Mehmet K Aug 27 '13 at 08:04
  • You can [answer your own question](http://meta.stackexchange.com/q/17463/163188). – trashgod Aug 27 '13 at 10:46
  • @howdoidothis [yes, but to override getPreferredSize for Plot2DPanel](http://stackoverflow.com/a/18315838/714968) – mKorbel Aug 27 '13 at 13:32
  • @trashgod I am not confident enough to actually answer it. Since I merely found a way around it, rather than a poper solution – Mehmet K Aug 27 '13 at 20:43
  • Go for it! You can cite @mKorbel's [example](http://stackoverflow.com/a/18315838/230513). – trashgod Aug 27 '13 at 21:30

0 Answers0