How do I create a correctly scaled x-axis? - axis

I'm using HighCharts line plots where my x-axis data is unevenly distributed:
[4, 10, 40, 100, 400, 1000, etc.]
Currently the x-values are placed evenly. I want the distance between x[5] and x[4] to be 10 times that between x[3] and x2. How do I do this?
In the GoogleCharts lingo, I need a continuous axis.
In the docs, I only see "linear", "logarithmic", and "datetime" for the axis type. ("linear" is the default and does not do what I want).

Since you didn't post your javascript generating the charts I'll have to guess, but I assume you are using categories within your xAxis. The categories are evenly distributed, so don't use them in this case.
If you change your series data block to specify x and y values (http://www.highcharts.com/ref/#series--data example 2) the xAxis will show correct proportions for your values. For example look at this fiddle.

Related

Can i set dynamic step size on stepped line chart in chart.js?

In chart.js, the x-axis of the stepped line chart are fixed.
for example, I want to displays when x is less than 2, y is 10, x is between 2 and 10, y is 20, x is larger than 10, y is 5.
How can i do this with chart.js?
By default the closest you can come is by using a logarithmic scale, only downside is you can't choose the tick spacing but it will increase.
The only way to achieve what you want is by writing your own custom axis as described here in the docs: https://www.chartjs.org/docs/master/developers/axes.html

MATLAB: colorbar on mapping tool based on point feature

Hi,
I could able to plot points on the map using geshow function based on value. I need to show a continuous stretched colorbar depicting these values. I don't know how to get so. The colorbar in right doesnot represent these values in the map. Please suggest me how to get so. Thanks!
You can put your own tick label on the colorbar, for example :
colorbar('Ticks',[0, .2, .4 , .6, .8, 1],...
'TickLabels',{'val_1,'val_2','val_3','val_4','val_5','val_6'})
Here, 'Ticks' are values on the colorbar itself, and 'TickLabels' are values (must be represented as strings) that you wish to display instead.

MATLAB: Density-time Plot

I have 11 1x50 matrices that contain densities. The first looks like [20, 20, 20... 20] and represents time=0. The second looks like [20, 19, 22,..], etc. and represents time=100. These continue to vary until t=1000.
What I'm hoping to do is to create a plot with the elements' position on the x-axis (50 positions for the 50 pieces of data in each) and time (0-1000) on the y-axis. Ideally, I'd like the plot to be completely filled in with color densities, and a colorbar on the side that shows what densities the color range represents.
Any help would be greatly appreciated!
Sort of inspired by: http://www.chrisstucchio.com/blog/2012/dont_use_scatterplots.html
Assuming you have (or can arrange to have) all those vectors as columns of a 11x50 matrix:
A = randi(100, 11,50); %//example data
you can just use
imagesc(1:50, 0:100:1000, A)
colorbar
axis xy %// y axis increasing, not decreasing
Example:
Looking at the comments, it will be easier to stack these vectors into a 2D matrix. You have 11 individually named vectors. Assuming that your vectors are named vec1, vec2, vec3, etc., create a 2D matrix A that stacks these vectors on top of each other. Also, you'll need to include an extra row and column at the end of this matrix that contains the minimum over all of your vectors. The reason why this is will be apparent later, but for now take my word for it as this is what you need.
In other words:
A = [vec1; vec2; vec3; vec4; vec5; vec6; vec7; vec8; ...
vec9; vec10; vec11];
minA = min(A(:));
A = [A minA*ones(11,1); minA*ones(1,51)];
As such, the first row contains the information at time 0, the next row contains information at time 100, etc. up to time 1000.
Now that we have that finished, we can use the pcolor function to plot this data for you. pcolor stands for pseudo-coloured checkerboard plot. You call this by doing:
pcolor(A);
This will take a matrix stored in A and produce a checkerboard plot of your data. Each point in your matrix gets assigned a colour. The colours get automatically mapped so that the least value gets mapped to the lowest colour while the highest value gets mapped to the highest colour. pcolor does not plot the last row and last column of the matrix, but pcolor does use all of the data in the matrix. In order to ensure that the colours get properly mapped, we need to pad your matrix so that the last row and last column get assigned to the smallest value over all of your vectors. As you want to plot all values in the matrix, that's why we did what we did above.
Once we do this, we'll need to modify the X and Y ticks so that it conforms to your data. As such:
pcolor(A);
set(gca, 'XTick', 0.5:5:51.5);
set(gca, 'XTickLabel', 0:5:50);
set(gca, 'YTick', 1.5:11.5);
set(gca, 'YTickLabel', 0:100:1000);
xlabel('Sample Number');
ylabel('Time');
colorbar;
What the code does above is that it generates a checkerboard pattern like what we talked about. This labels the Sample Number on the x axis while time is on the y axis. You'll see with the two set commands that I did, this is a bit of a hack. The y axis by default labeled the ticks going from 1 - 12. What I did was that I changed these labels so that they go from 0 to 1000 in steps of 100 instead and I also removed the tick of 12. In addition, I have made sure that these labels go in the middle of each row. I do this by setting the YTick property so that I add 0.5 to each value going from 1 - 11. Once I do this, I then change the labels so that they go from 0 - 1000 in steps of 100. I also do the same for the x axis in a similar fashion to the y axis. I then add a colorbar to the side as per your request.
Following the above code, and generating random integer data that is between 13 and 27 as per your comments:
A = randi([13,27], 11, 50);
minA = min(A(:));
A = [A minA*ones(11,1); minA*ones(1,51)];
We get:
Obviously, the limits of the colour bar will change depending on the dynamic range of your data. I used randi and generated random integers within the range of 13 to 27. When you use this code for your purposes, the range of the colour bar will change depending on the dynamic range of your data, but the colours will be adjusted accordingly.
Good luck!

Increase resolution in X-axis for an existing x-y graph in MATLAB

In MATLAB, I have an existing set of values for X,Y where X = [0,1,2, ... 255], and Y is in the range of -5 to 4.
When I plot this graph MATLAB, obviously interpolates these values.
I require to increase the resolution of the X-axis to X = [0, 0.25, 0.5, 0. 75, 1 .... 254.75, 255].
I am not looking for a simple averaging kind of operation. Rather I want it to be as good as MATLAB which does it very smoothly. Please guide me.
A few things to know:
Matlab doesn't interpolate if you haven't made it interpolate. The figure you see is scalable, so there is no interpolation, at most a line connecting between adjacent dots.
If you want to interpolate just use interp1....
fore example,
Xnew= 0:0.25:255;
Ynew=interp1(X,Y,Xnew,'spline');
plot(Xnew,Ynew);
should do.

SSRS 2008 - Line Chart - How to shade an area of the chart?

I have a line chart. The line represents the average thickness of material we apply to glass. The Y Axis represents the thickness and the X axis represents time. Say the range of values on the Y axis is between 1 and 10. The average thickness is say typically between 3 and 5, but must fall within a range, on the low side of 2 and on the high side of 7. I would like to shade the area of the graph between 2 and 7, to indicate the acceptable range of values. Can this be done?
Add a second value series, and change it to the "Range" chart type. This will allow you to set the high / low Y values discretely. Rather than choosing a field for these values, just edit the expression and set the static values (in your case, 2 and 7).
From there, edit the series "fill" properties - select Pattern, and find one that works for ya. There a good set of % fills (5 percent, 10 percent, etc.) midway down the list.
Hope this helps.