About Y-axis in JFreeChart - java

The left three lines of data: 0.9,2450,0.4867 in the Y-axis is shown in proportion.
Right three lines (the other two data is too small to show up), how to do the left?

I see several alternatives:
Condition your data to show relative change, as is done in the chart on the left.
Add a second axis to show the larger dynamic range, as is done in DualAxisDemo2.
Enable the zoom feature in ChartPanel, as suggested in this example.

Related

How can I graph values that are incredibly small in Java?

Basically I am attempting to use JFreeChart right now to graph some values. The only problem is that the values are incredibly minuscule, e.g 7.069781E-13. I believe these values are too small for JFreeChart to display. How can I display these small values visually in Java in a line chart format?
It looks like this currently:
And I want to make it look similar to this:
I found a work around.
I simply multiplied all the values by a factor of 100 so the graph now looks similar to the one in the example. I will include a disclaimer in the legend saying the chart has been multiplied by a factor to clearly see the line chart.
Also consider these alternative:
Invoke setRange(), seen here, to expand the y axis in the area of interest.
Add suitable controls, seen here, to control y zoom.
Advise users how to use the mouse for zoom control, as shown here.

How to make axes equal size in regards to pixels?

I'm using JChart2D for visualization. I would like to make the X and Y axis equal in terms of pixels. By doing so its much easier to see how far the points are from each other in euclidean distance (see image). As it is now, the x-axis is more stretched out. They already have the same range in terms of values.
The framesize defines the pixel values right now, i.e:
jFrame.setSize(800,600);. Everything then dynamically fits inside the frame where the Chart2D resize itself to make space. I find the pixels manually, but that seems stupid. Also, if i have a scenario with a lot of clusters, the legends line will wrap and thus resize the chart.
I've googled a lot and looked at the documentation, but I've been unable to find a solution.
So how do i set the chart to a fixed size, that's independent from the other items in the frame?
Image example:
What do you expect if you would make it and still insist on the JFrame to be non-rectanguar to be displayed in the remaining 200 px in x range? The void grey?
You could achieve this e.g. by setting a GridBagLayout to the JFrame.getContentPane() and define a grid of two vertical cells - one grid to take 600px x 600px and the second to take 200px x 600px. But then you have the void in the 2nd pane. HTH, Achim
By doing so its much easier to see how far the points are from each
other in euclidean distance
not really, the Euclidean Distance requires at the end the position of the 2 points you are calculating and you have it... otherwise you wouldnt be able to plot anything in the canvas..
another aproach that you can use is implement a ViewPort over the canvas but that makes sense only for zoom in/out images and tht is not your case...

Using different x-axis labels for n lines in a graph

So I am using MPAndroidChart as library for the viewing of graphs in my app. Now I wanted to make a LineGraph with several lines (n). The problem is that those lines do not have the same x-axis labels and I have not found a solution to put the x-axis labels in relation to the entries. Furthermore does the new line start at x-value 0. Therefore my lines do not fill the entire diagram area. Because when I have two lines with 6 entries each, the x-axis labels have the size 12. And therefore the lines end at half of the diagram.
How do I solve that?
Example LineGraph
I assume you mean the library available here: https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/LineChartActivity2.java
From the code I grasped, LineChart does not support dual x-axis (while it support dual y-axis, left and right). See here , XAxis.java and YAxis.java
On the other hand, looks like the x-axis fits the data range automatically (there is no method to set min/max of x-axis).
An example of the graph >>
I would suggest you to re-organize your chart to switch x and y axis, and use two y axis if your series have different range of y values, but you want to show them in a chart. Double y-axis is more common than double x-axis from my experience, and easier to understand as well.

Draw line chart in Java using JAVAFX

What i want to do:
How my program looks like:
So currently i have a table which contains elements. I thought the right idea would be maybe work with lines and circles to draw graph? Or is there a better alternative? Also the main question here is how to set a layout, so if there's an element number one it has a circle under it and if the element is 15 it has an element under it. My thought is for every circle to has it's own row, if one has been placed the next one is 10px below etc. Although still the question remains about layout, any pointers?
E:/
I came up with a little idea to use Line Chart, but the Line Chart doesen't allow me to manipulate it with the way i want. It will just create lines in ascending order but i would like to move from point one to point five and then to point 2 (as shown in the chart above with different elements but the idea is same).

Remove an axis from JavaFX Chart

I've created a XYChart with numerical values different (for example temperatue with pressure) so I want to draw my own axeS just beside my chart. To do the following I've to unshow the YAxis, how should I do that ?
By using a trick: The Chart needs the Y Axis to remain in place so it knows where to render your content. You can, however, hide it. Hide the tick labels and set the axis' opacity to 0 using this code:
chart.getYAxis().setTickLabelsVisible(false);
chart.getYAxis().setOpacity(0);
The axis will still be there, but not shown.
I found that if I hid the chart using the following code:
chart.getXAxis().setTickLabelsVisible(false);
chart.getXAxis().setTickMarkVisible(false);
((Path)chart.getXAxis().lookup(".axis-minor-tick-mark")).setVisible(false);
Then I get about ~10 pixels less blank space on the bottom. IF the space was an issue for your application then you could use css offsets to correct it. This solution may have more predictable offsets.
SOLVED: I got this to work for sharing a common x-axis for two charts stacked vertically:
Create two charts, each with their own identical copy of the x-axis object, setting identical upper and lower bounds (optionally by binding).
Then hide the x-axis in the second chart like this:
chart = new LineChart<Number,Number>(xaxis2,yaxis2) {
{// hide xAxis in constructor, since not public
getChartChildren().remove(getXAxis());
// not getPlotChildren()
}
};
You'll want to set the widths of your y-axes to be the identical, e.g.
int w = 60;
yaxis.setMaxWidth(w);
yaxis.setMinWidth(w);
yaxis.setPrefWidth(w);
yaxis2.setMaxWidth(w);
yaxis2.setMinWidth(w);
yaxis2.setPrefWidth(w);

Categories

Resources