Unable to add Trend Line in Tableau even though both axes are numeric - tableau-api

As shown in the screenshot: both axes are numeric. So why can not the trend line be calculated?

The problem with this set up is that the values on the x-axis are discrete values rather than a measure.
Tableau treats every number as a separate category rather than a point on an axis.
If you click on that field and chose "Convert to measure", you should get an actual scatterplot and you should then be able to add a reference line for each axis.

Related

Adding x error bars to a scatter plot in tableau

I have a scatter plot in tableau:
I am looking to add error bars to the points but cant find how to do this. I would need to specify the lower limits and upper limmits (i.e. not just a fixed percentage of the value). The only thing I can find is adding y errors in the form of a gant plot but this isnt helpuful (I dont think) as I only need x errors.
Its possible with a combination of using Measure Values (to show lines between the error ranges) and a dual axis (to overlay the X values on the lines)
See sample workbook

Matlab histcounts show values on x-axis

I want to draw a histogram, using plot(histcounts(X,edges)).
It works fine, except that on the x-axis, the number of the bin is displayed, not the actual value the bin refers to.
To make a bit clearer what I mean, I append two plots. Both display the same data, but for the first one, I used plot(histcounts(X,edges)) and for the second hist(X,edges). The plot for which I used hist shows the x-axis the way I want it to look like, with the value the bin refers to. I would like the plot(histcount(...) to have the same x-axis, instead of showing the bin number.
Histogram using plot(histcounts):
Histogram using hist:
How can I change the x-axis to show this value instead of the bin number?
Thanks a lot!
If you have the edges, you can get the centres using
centres = edges(1:end-1)+ diff(edges)/2;
then the plot can be
plot(centres, histcounts(X,edges));
If you do not need to specify the edges you can get them using
[h_counts, edges] = histcounts(X);

Tableau Control Chart - Attribute measure incorrect

All
I have a control chart, with on the X-axis a time period, and the Y-axis the value of the measure (I'd like to plot all the points in a control chart).
However, I have 2 different values as a measure, which have the exact same date (up to a second match) but different measure values.
When I plot this on a control chart, instead of having 2 points in the control chart with value 500 and 550 for example - it gives me one point with a value of about 200.
It also gives a notification that there is a NULL value in this axis, which points to the X-axis where 2 records have the exact same date.
Any idea what I can do to make this correct - or make tableau draw the measure points correctly?
Thanks in advance!
It's difficult to answer without seeing more detail about your problem, but this sounds like a good candidate for a blended axis. (multiple measures sharing a single axis)
The easiest way to do this is to put your (probably continuous) datetime field on the row axis and one of your measures on the row axis to see one of then control plots. Then drag the second measure to the Y-axis until you see a little translucent two bar icon to indicate that you are adding a second measure to that axis, at which point you can release the pointer and you should see a two plots on the same axis.
If the scales for the two measures are radically different, you can instead drag the second measure to the right side instead to get a dual axis.

How do i display all the date in x axes

I am using Matlab to plot a graph but i am not getting all the date's in x axes. for example first date starts off 21/2/2013 next date continues as 21/2/2012 but it should be 21/2/2013, 24/2/2013 etc... is there a way to accomplish this? This is the syntax i am using for plotting my graph:
plot(dates,mean([h,l],2),'--r','LineWidth',2)
I am using date as an array, i found out that i can use Units but it does not work
Also is there any way i can add a graph side by side so first graph should appear on right side where the second graph should appear on left hand side. Is this to do with GUI or do i am have to position these graph specifically in a greed
there is a function for that
see
http://www.mathworks.com/help/finance/dateaxis.html
also make sure that the "dates" variable, holds the dates not strings (e.g. 744564)
You want to set the tick marks to something custom I believe. Assuming tickDates has all of the date values where you want a tick value:
plot(dates,mean([h,l],2),'--r','LineWidth',2)
set(gca,'XTicks',tickDates)
As far as side by side plotting, you want to use subplots.
subplot(2,1,1)
plot(dates,mean([h,l],2),'--r','LineWidth',2)
subplot(2,1,2)
For more, see http://www.mathworks.com/help/matlab/creating_plots/setting-axis-parameters.html

MATLAB: Plotting two different axes on one figure

The MATLAB surf plot below is essentially two plots plotted adjacent to each other. For clarity, I have included some code below used to prepare the plot:
band1 = horzcat(band1, eSurface2(:,:,1));
band2 = horzcat(band2, eSurface2(:,:,2));
surf(band2,'DisplayName','band2');
surf(band3,'DisplayName','band2');
I would like for the y axis numbering to restart at the start of the second graph. How do I go about doing that?
You can use the 'YTick' and 'YTickLabel' properties of the axis to control the ticks, this way you can make it start from zero for the second graph. It will require some trail and error to get it right. See the relevant doc here (you'll have to scroll all the way to the bottom of the page).
Take advantage of the following feature of 'YTickLabel': "If you do not specify enough text labels for all the tick marks, MATLAB uses all of the labels specified, then reuses the specified labels".