Residual analysis and subtracting values between scatter plots - tableau-api

I am trying to subtract the two corresponding values for each of the scatter plots to get a residual. Each point on the scatter plot below has a corresponding point in the plot above, but simply with a different value. For example, NE at the very left has a value of 0.5 in the top scatter plot and I'd like to subtract from it the value in the bottom plot which is 1. I have been trouble doing this. I couldn't get a level of detail calculation to work, because that aggregates everything, and I simply can't make a table calculation of avg(average scores) - predicted score. The predicted score is really just a trend line fitted on to the top scatter plot. Any help is appreciated.

Related

Create plot between two points representing confidence intervals in R

I have a data frame similar to the one created in the example below:
Remove columns with zero values from a dataframe
Is it possible to create a whisker plot connecting these two points in R? I would want the variables on the x-axis and the points on the y-axis.

Aligning histogram plots

I have a given data set, and I want to compare the histograms of this data when represented as a bar histogram and a line histogram. Specifically, I want to use
myhist = histogram(mydata)
to get the bar histogram, and plot on the same figure a line histogram using
mylinehist = plot(myhist.Values)
However, when I do that, I get the following figure
It seems like the line histogram mimics the shape of the bar histogram, but offsets it by a certain amount on the x-axis. Is there a way to align the two so I can have them overlapping? I tried using a command like
align([mylinelist,myhist],'Left','None')
but to no avail. Thanks!
You need to specify the x-axis values for your line plot. These should be the midpoints of your histogram bins.
Try:
midpts = myhist.BinEdges + (myhist.BinWidth / 2);
plot(midpts(1:myhist.NumBins), myhist.Values);

Creating a Bar Graph where each Bar is a Histogram

I'm creating a line plot, where the y value of each point is the average value of vector i. The x value of each point is i.
I want to visualise the distribution of numbers in each vector, preferably all on the same graph.
Is there a way I can make a bar graph, where each bar, i, is something like a colorbar, representing the histogram of vector i. So essentially I want to end up with 20 or so bars, each being a histogram.
Or if there is a better way to visualise numerous histograms on a single plot, I'd like to hear it.
I solved the problem using Dan's solution. I took a histogram of each vector (with specific bin intervals), and stored them all in a 2D matrix (Each column is a complete histogram). Then displayed it with image() (Don't have access to imshow).
I did have to mess around with the axis labels though, as the image() function was plotting it according to the coordinates of the 2D matrix, rather than the values in the original vectors. Fixed that up with some calls to set(gca,'YTickLabel/YTick'). Also had to set the YDir back to 'normal' rather than 'reverse'. I think image() was flipping it.

How to set an arbitrary direction on a contour plot to perform operation in Matlab

I am looking for help for my particular problem.
I have a contour plot created from XYZ data. This plot contains 2 broad peaks with one more intense than the other.
When the most intense peak is aligned with the Y axis, I can perform a fitting of every YZ curve at each X values. I usually do a gaussian fit to plot the peak center on the same graph.
In some cases I need to perform the same fitting but no along the Y axis direction (in this case I just plot YZ scan at every different X values) but along another arbitrary direction.
For the moment the only way I found is the following:
-plot the contour plot and find for the position of the most intense peak
-if the position is not aligned with the Y axis, then rotate all the datas and plot again the contour
-perform the YZ gaussian fit for every X value
- Rotate the resulting XY position to go back to the original plot
-plot the XY position as a line on the original contour plot
this is quite long and requires a lot of memory. i would like ot know if there is a more elegant/faster way.
Thanks for your help
David
I take it you want to extract data from the (x,y,z) data along some arbitrary line in order to make a fit. A contour plot will show only part of the data, the full z(x,y) data can be shown with imagesc etc. Say you want the data along line defined by two points (x1,y1) -> (x2,y2). According to the eq of the line, the line y=a*x+b the slope a is (y2-y1)/(x2-x1) and b=y1-a*x1. For example, I'll select (x,y) coordinates in the following contour:
Create data and end points:
m=peaks(100);
x1=11 ; x2=97;
y1=66; y2=40;
Thus the line parameters are:
a=(y2-y1)/(x2-x1);
b=y1-a*x1;
and the line is:
x=x1:x2;
y=round(a*x+b);
select the proper (x,y) elements using linear indexing:
ind=sub2ind(size(m),y,x)
plot:
subplot(2,1,1)
contour(m,10); hold on
line([x1 x2],[y1 y2],'Color',[1 0 0]);
subplot(2,1,2)
plot(m(ind))
You can now use vec=m(ind) to fit your function.

What exactly Scatter Plot in Core Plot?

What exactly Scatter Plot in Core Plot?
In my application,I am plotting values & join them except null values.If the null value is there in between then the plots are not joined.Is it the right way to plot values in Scatter plot?
Yes, that is the way scatter plot works in coreplot. Scatter plot is represented by joining the co-ordinate points using a line. If some data is missing, it will be represented by a broken link in scatter plot.
Alternatively you can try to represent a null value using zero value for that corresponding axis value and it can be represented as a sudden dip in the graph at that portion, but that again depends on your specific requirement.