If Measure Value = Something Then X Else Y End - tableau-api

I have 2 lines as measure values and I would like each line having their own % information but I cannot do that as a Text. Any workaround to get it to work?
Tableau file sample:
https://www.dropbox.com/s/1upehg61rg5psas/Percentage_on_success.twbx?dl=0

You should try a dual-axis with your two line measures and put the bars as reference lines. See this as an example. You can't independently control the Text on "Measure Values" because it is treated as a single measure.

Related

How to force a line break in a legend of a boxplot?

I need help to skip lines in the legend of boxplots : I have a plot with two boxplots, and each of them has a legend to long to fit on a single line.
I tried this, X being my matrix of data (two colums) :
boxplot(X,'Labels',{'1stpartofthelegend\newline2ndpartofthelegend','1stpartofthelegend\newline2ndpartofthelegend})
This solution works in other types of plots, like a plotspread plot so I don't understand why it is not working here ?
I found this question, but the solutions are not working for me, maybe because I have a more recent version (R2018b).
I actually want to add my boxplots over a plotpsread plot, but when I do that the legends of the boxplots win over the legends of the plotspread (even if I add boxplots without legends, the previous legends of the plotspread are replaced by "1" and "2"). So preventing the boxplot to erase the previous legend would be a nice solution but as I failed to do that I tried to find another way.
Thank you for your help
You want to set the 'Labels' of the boxplot for multiple lines. So use a cell of cells:
Lbl = { {'1st entry (1st line)','2nd entry (1st line)'},...
{'1st entry (2nd line)','2nd entry (2nd line)'} };
boxplot(rand(100,2),'Labels',Lbl)
EDIT
LaTeX commands work in the title and labels but apparently there is no interpreter or TickLabelInterpreter property for boxplot-Labels:
Error using internal.stats.parseArgs (line 42)
Invalid parameter name: TickLabelInterpreter.

Justify legend text in Matlab

I have the legend shown below:
On the left, the text is aligned, however, on the right the numbers are not aligned. How can I align the numbers too?
The tab command (\t) does not seem to work when providing strings to table entries. However, you can solve the problem if you work in the latex environment, define every entry as a single-row tabular and define the first column to have a specific width (e.g. 1 cm):
plot(eye(2)); % example plot
h=legend('\begin{tabular}{p{1cm}r}first:&1\end{tabular}',...
'\begin{tabular}{p{1cm}r}second:&2\end{tabular}'); % table entries in latex
set(h,'interpreter','latex'); % set interpreter

Stair plot to vertical bar plot in Matlab

I want to create a vertical bar plot. This is my code:
bar (x, sensiv);
title ('Promedio X')
xlabel('Nm')
ylabel('Refl.')
The problem is it looks like a stair plot. I've tried to add (x,sensiv, 'stacked') but it doesn't work. It looks grouped, as you can see in the next image:
graph http://imageshack.us/a/img689/9449/capturawv.jpg
I think it's because of x-axis but I couldn't change it. How can I do it? Does somebody knows how can I do it?
EDIT
Thanks Colin! I've tried to zoom and I understand what you mean and I've tried with different values, as slayton and you said.
I think that maybe it's the way I've code the plot, it is possible?
abc=0;
for p=(61:201)
abc(p)=out1_c;
end
for p=(151:301)
abc(p)=out2_c;
end
for p=(231:380)
abc(p)=out3_c;
end
for p=(381:596)
abc(p)=out4_c;
end
for p=(1152:1531)
abc(p)=out5_c;
end
for p=(1651:2051)
abc(p)=out7_c;
end
for p=(2052:2151)
abc(p)= 0;
end
The default value for the width of the bars in a bar plot is 0.8, so given that you're not currently specifying the width, you should have gaps in between each bar. This is going to sound really obvious, but have you tried zooming in on the bar plot that is created? For some datasets, the bar function will return a plot that looks like a stair plot, but in fact has gaps if you zoom in far enough. If this is the case, then you should be able to get the gaps you want by tinkering with the width parameter as suggested by slayton.
EDIT
Okay. First things first. If you want to post additional information, you should add it to your question, NOT post it as a new answer! You can do this by clicking the edit button just below where your question is on the page. To make things more readable, you might preface your edit with a capitalized bold-face heading "EDIT" as I have done here. If you are able, try now to move the additional information you've given back into your question, and then delete the answer.
Second, I have to be honest, the additional information you posted was somewhat confusing. However, I think I understand what you want now. You want 7 bars coming up to the heights out1_c, out2_c, ..., out7_c (variable names taken from your additional information) with a small gap between each bar, and the x-axis to reflect (approximately) the intervals 450-550, 550-650, etc.
Well, if you want 7 bars, then you want your input to only have seven elements. Set:
y = [out1_c; out2_c; out3_c; out4_c; out5_c; out6_c; out7_c];
y now gives you the heights your bars will come up to on the y-axis. To locate the bars on the x-axis, define a vector x that also has seven elements, where each element gives the midpoint of where you want the bar to be on the x-axis. For example:
x = [100; 200; 300; 400; 500; 600; 700];
Then just use bar(x, y). This should get you started.
A final point on the code you posted, you can actually completely avoid the loops: read up on vectorization. But if you are going to insist on loops, the first and most important rule is to preallocate your vectors/matrices. In your code abc starts out as a scalar (a 1 by 1 matrix), but then for every p, you are adding an element at index p. What is actually happening in the background is for every p, matlab is scrapping the current abc you have in memory, and building it again from scratch with the additional element. As you might expect, this will slow down your code by many orders of magnitude.
You can set the width of the individual bars by passing a value between 0 and 1 to bar. Passing 1 indicates that there should be no space between the bars
bar(x,y,1)
Passing anything less than 1 will reduce the bar sizes and introduce spacing between the individual bars
bar(x,y,.5)

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 !

SSRS:How to Add a Trend Line Series to Chart which has only 1 Point on X Axis

The reason I need this is,my chart is inside a Tablix and Only 1 Value(X-axis point) gets supplied to each Row
I can see this line which is centered to chart(as per X-axis) .I want it to run from (X,Y)(0,0) till end of Chart
Pavan,
The trend line is the result of a linear regression and, as such, will need more than one observation in order to be calculated.
For a cloud of data to define the line that represents its trend (a trend line must be unique, that is why I refer to it as "the" trend line, and not "a" trend line), it is necessary that there are, at least, two points in it. With one point you can draw an infinite number of lines - no unique solution.
Anyway, if you want simply a line - and not specifilcally the trend line - you can add a series to your graph with a given number of repetitions of your single value.
Hope this helped...
Julio
Julio,Thanks. I had same thought, so took a step back and got around the problem using Stripline property on vertical axis