MpAndroidChart - How to set the same space between the x-axis label? - charts

According we can see in this image, the size of the last x-axis area is less that the others. With this, the Sunday looks less that the other days of week..
How can I put he same distance between the x-axis grid?
I'm drawing 4 points for each day of week. So, my X-values are
{Mo,Mo,Mo,Mo, Tu,Tu,Tu,Tu ... Sun,Sun,Sun,Sun}
and
xAxis.setLabelsToSkip(4);

You may enable the horizontal scroll bar by
lineChart.setHorizontalScrollBarEnabled(true);

Related

How to adjust bar absolute width in MATLAB

I'm confused with the bar with adjustment in MATLAB, for example, when use bar like:
bar(randsample(0:0.0001:1,100),randn(100,1))
I get an image like this:
It seems like the bar is too thin to have a good look. After searching for help, I can use the code like:
bar(randsample(0:0.0001:1,100),randn(100,1),50)
and I get this:
Seems much better. But if I change the sample number from 100 to 10, the same code won't work.
bar(randsample(0:0.0001:1,10),randn(10,1),50)
I hope I have explained my issue clear. It seems like the third parameter of the bar function is a relative width, which correlates to the input size of the first and second parameter. Can I fix the absolute bar width no matter how many data points input? or there is a better function to draw figures like this? Thanks a lot for any help!
user #am304 is right about the width parameter
What happened in your code is that you set x values to results from randsample(0:0.0001:1,10)
If you give your plot a width of 1 it means that 2 bars which are directly next to each other would touch each other with an equally spaced x.
In your case, you have an irregular x spacing.
The width of the bar is determined by the minimum distance between two x values (which you get from randsample()). Sometimes this space - and therefore the width of your bar - is very tiny. Sometimes it is broader.
Change the with to 1 and make multiple plots. You will notice that two are always touching each other and no one is overlapping and all the others have spaces in between. If you change the width to 50 the plots will somethimes overlap heavily (depending on the randomness from randsample) because your bars are 50 times bigger then the minimum width between two x values.
In case of your randsample(0:0.0001:1,100) example it is just more likely that two values are close to each other, therefore increasing the width helps you see something (because the bars overlap).
From the documentation:
bar(___,width) sets the relative bar width, which controls the
separation of bars within a group. Specify width as a scalar value.
Use this option with any of the input argument combinations in the
previous syntaxes.
The example provided is as follows:
Set the width of each bar to 40 percent of the total space available
for each bar.
y = [75 91 105 123.5 131 150 179 203 226 249 281.5];
bar(y,0.4)
So bottom line is: the width is specified as a % of the total space available for each bar. Yoru problem comes from the fact that you have far too many bars, so the space available for each bar is tiny. Setting the width to 50 or 5000% of the space available just means that each bar will overlap quite substantially on the neighbouring bars. Because you have so many, the middle plot looks "reasonable" as I suspect a lot of the bars are overlapped and a lot of them are at zero, so you just can't see them. If you go down to a sensible number of bars, as in your last example, then setting the width to 5000% looks ridiculous as you found out.
So to summarise: reduce the number of bars and specify the bar width between >0 and 1 (1 being no gap, all the bars touching each other).
A better way to plot things with random x locations is to use stem. By default, it draws a line from the zero line to the datum, with a circle representing each datum. But this can be modified. For example:
stem(randsample(0:0.0001:1,100),randn(100,1), 'Marker','none', 'LineWidth',4)
creates a plot similar to your second attempt, but with bars of a fixed width (4 points).

Display same scales on both y axes on a dual line chart

I have a dual axis line chart that shows the number of planned hours vs worked hours through time (week number). Even though they are both Hours, I had to create a second axis for worked so that I get both of them displayed on the same chart.
But as you see in the picture, they do not quite show the correct scales (Worked hours is in thousands (0K, 2k, 4k, etc) while planned hours is in singles (0, 200, 400).
How can I edit my chart so they both show the same scale?
P.S. As long as I get both of these measures on the same chart, I really don't mind skipping the dual axis part. In fact, if both measures have the same scale I don't understand why one should create dual axis.
You should be able to just right click on the axis on the left and in the menu there should be an option to "synchronize axis". Select this and it will sync the two axes.
You can then hide the axis on the right to make it appear like a regular line graph and not a dual axis. To do this right click on the axis and uncheck the "show header" option.

How Do I Keep All Series Labels on a 3D chart

Suppose that I have a list of 40 planets (OK some are from another solar system). Astronomers have counted the number of meteors hitting the planets from January to December. So I have 40 rows of 12 columns of data.
When I plot a 3D chart the planets are displayed on the depth axis, the months January to December are on the Category axis, and the number of meteors on the value axis.
But some of the planets are missing. It seems SpreadsheetGear or Excel is treating the planets like numbers.
How do make SpreadsheetGear display all planets on the depth axis?
PS. I reviewed all related Spreadsheetgear docs but I couldn't find how to do this and checked StackOverflow for related questions but didn't find any.
Thanks, CoolBreeze
I think I solved my own problem:
1) I increased the width of the chart when I called AddChart:
ChartObj = m_WorksheetObj.Shapes.AddChart(Left, Top, Width, Height).Chart
2) I set TackLabelSpacing = 1
Dim DepthAxis As IAxis = ChartObj.Axes(AxisType.Series)
DepthAxis.TickLabelSpacing = 1
I'm not sure if that is the best solution but it appears to work for me at the moment.
If I add more planets the labels will be closer together and it'll be harder to read the labels. I'll have to widen the chart some more to spread out the labels to make them easier to read.
I added numbers in front of the planet names so when I looked at the list of planets on the chart I could see 1-40 and I knew all planets were listed.

Sigmaplot: How to scale x-axis for correctly displaying boxplots

I want to display overlapping boxplots using Sigmaplot 12. When I choose the scale for the x-axis as linear then the boxes do indeed overlap but are much too thin. See figure below. Of course they should be much wider.
When I choose the scale of the x-axis to be "category", then the boxes have the right width, but are arranged along each single x-value.
I want the position as in figure 1 and the width as in figure 2. I tried to resize the box in figure 1 but when I choose 100% in "bar width" than it still looks like Figure 1.
many thanks!
okay, I found the answer myself. In Sigmaplot, there is often the need to prepare "style"-columns, for example if you want to color your barcharts, you need a column that holds the specific color names.
For my boxplot example I needed a column that has the values for "width". These had to be quite large (2000) in order to have an effect. Why ? I have no idea. First I thought it would be because of the latitude values and that the program interprets the point as "1.000"s, but when I changed to values without decimals, it didnĀ“t get better.
Well, here is the result in color.
Have fun !

Core Plot - Disable axis labels for certain ticks

How would I disable the axis labels for certain (not all) ticks?
For example, my x-axis corresponds to the start time of an event. The x-axis label shows the date of the start time. However, there may be multiple events in one day, and instead of multiple labels displaying the same date, I'd like for only the first occurrence of the date to be shown, and remaining labels with the same date hidden.
Thanks in advance.
Looked around and found this can be done with labelExclusionRanges.
From Core Plot documentation:
CPTAxis: [read, write, retain]
An array of CPTPlotRange objects. Any tick marks and labels falling inside any of the ranges in the array will not be drawn.