JFreechart - How to set Domain Axis range? - range

I'm newbie in JFreechart. I've a dataset which contains more records(>50 ) i.e (the X-values are products and Y-Axis are quantity) , in the chart i want to display only first 15 records in the X-axis. I'm using CategoryAxis like.
final CategoryPlot plot = chart.getCategoryPlot();
final CategoryAxis domainAxis = plot.getDomainAxis();
Anyone please guide me to do this.?

This doesn't appear to be an axis problem. One simple expedient would be to add only the desired records, but SlidingCategoryDataset would allow you to setFirstCategoryIndex(0) and setMaximumCategoryCount(15).

Related

Add labels for x and y using the plotmatrix function MATLAB

I managed to plot a matrix (16X16) but I want to add labels for each single x and y axis's. As shown below, the labels are written vertically on the y and mixed with each other and also written on the x graph itself and also mixed. Is there a way to add the labels beside the axis without being mixed (as show in the second photo)?
Current graph:
What I want to do:
My code (just stopped after plotting three label as it wasn't working):
[~,ax] = plotmatrix(corr);
ylabel(ax(1,1),'ABCDEFGHIJKLMNOP')
ylabel(ax(2,1),'ABCDEFGHIJKLMNOP')
ylabel(ax(3,1),'ABCDEFGHIJKLMNOP')
xlabel(ax(16,1),'ABCDEFGHIJKLMNOP')
xlabel(ax(16,2),'ABCDEFGHIJKLMNOP')
xlabel(ax(16,3),'ABCDEFGHIJKLMNOP')
If I understand your problem you want to be able to give individual y-labels for the rows and x-labels for the columns. Unfortunately when you use xlabel and ylabel the resulting text overlaps. Here are two solutions
Solution 1: Use the big-axes to set the labels
Use single label for the horizontal axis and vertical axis by referencing the big-axes
[~,~,HBigAxe] = plotmatrix(corr);
xlabel(HBigAxe,'Horizontal Label for Columns');
ylabel(HBigAxe,'Vertical Label for Rows');
Solution 2: use rotation and alignment to avoid overlapping labels
If you want each row and column to have there own labels you can rotate and set the horizontal alignment of the label. For example:
[~,ax] = plotmatrix(corr);
ylabel(ax(1,1),'Y Axis Label','Rotation',0,'HorizontalAlignment','right')
xlabel(ax(end,1),'X Axis Label','Rotation',90,'HorizontalAlignment','right')

Matlab 2016a - how to get xTickLabels on only some of the xTicks on an imagesc?

I'm trying to create a 24x366 heatmap using imagesc with the x-axis labelled at 13 evenly spaced points as {'jan 15','feb 15',...,'dec 15','jan 16'}, and the y-axis labelled at every row from 1 to 24, like this:
Desired imagesc axes
When I run the script, it displays the y-axis as I want it, but it only displays the first label on the x axis and ignores the others. I can get this to work for a plot, but I can't get it to work for an imagesc. I've included my script below. Does anyone know how to make the imagesc display all 13 labels on the x-axis at evenly spaced intervals?
mylabels = {'jan 15','feb 15','mar 15','apr 15','may 15','jun 15','jul 15','aug 15','sep 15','oct 15','nov 15','dec 15','jan 16'};
testspacing = (1:(60*24*30):528480);
figure
imagesc(rand(24,366))
set(gca,'XTick',testspacing,'XTickLabel',mylabels,'XTickLabelRotation',45,'YTick',1:24,'YTickLabel',1:24)
The problem with your code is that your only one of your ticks from testspacing falls in the range of the plot testspacing=[1 43201 ...]. You can check the range of your x-axis by running xlim without any arguments.
You can rescale testspacing to fit your x-axis e.g. like:
xmax = 366;
mylabels = {'jan 15','feb 15','mar 15','apr 15','may 15','jun 15','jul 15','aug 15','sep 15','oct 15','nov 15','dec 15','jan 16'};
testspacing = (1:(60*24*30):528480);
testspacing = testspacing/max(testspacing)*xmax;
figure
imagesc(rand(24,xmax))
set(gca,'XTick',testspacing,'XTickLabel',mylabels,'XTickLabelRotation',45,'YTick',1:24,'YTickLabel',1:24)
or you just generate testspacing properly. Since you are putting own labels on the axis anyway you might just choose use testspacing = [0:30.5:366] or testspacing = [0:30:366] depending on what you want. This will also help you debug your own code later on.
On another note you should think about reducing the number of labels in general and decide which of the labels are really helpful. Maybe every 2nd or 3rd month is enough. You can "remove" individual labels by setting them to empty strings ''.

Multiple YAxis with different tick size

Just want to find out if anyone have encountered this problem before.
Basically I am currently using Flot version 0.8. I am trying to plot a chart with multiple yaxis against datetime in xaxis.
The Left yaxis are for values which normally range between 10-80 whereas right yaxis are for values range between 100-500.
Is that even possible to have them plotted with the same tick size (E.g., 20) and the dimension of the chart is fixed.
At the moment, FLOT will automatically apply different tick size on left and right yaxis.
What do you guys think?
Use the tickSize option to set the same interval on both axes. See the customizing the axes section of the docs for more info.

JasperReports (iReport) Chart Define X Axis Tickcount

Find a screen from my report attached.
It is an AreaChart with a category dataset in a multiple axis chart.
The Y Axis is well formed.
The X Axis is not.
The X Axis is based on a Timestamp field.
Can I configure the TickCount in iReport?
The X Axis has to be exploded like Y axis.
I´m working with actual iReport and don´t have permission to use Java.
thx and Best regards
Christian
Sometimes, un-checking and re-checking the tick-mark buttons in the chart's properties window will work..

Double sided bar chart?

Am new to coreplot framework, rite now am working in barchart model and got some idea bt now i want to do double sided barChart (i need y axis both left and right corner)
OtherWise i need to move this following range value for y coordinate when i move over the different x position on the graph....
plotSpace.globalYRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromInteger(0) length:CPDecimalFromInteger(100)];
plotSpace.yRange =plotSpace.globalYRange;
Thanks in advance
You can add as many axes as you need. If you want both y-axes to have the same scale, you can use a single plot space. See the Mac version of CPTestApp for an example of adding a third axis to the graph.