I am using 'listdlg' function with the Mutiple selection, so the user can select two different items from a list with Mutiple items. When two items are selected, I want the program to plot one bar graph. How would use 'if' or 'case' statements to do this.
The list:
rain
sun
snow
wind
for example, if 'rain and sun' are selected, it plots (x,y)
whereas if 'snow' and 'wind' are selected, it plots (s,t)
any help would be much appreciated thanks alot.
I used 'case statements', the case statements work however they just don't do what's expected
Related
I'm trying to create an app for data analysis.
I have multiple channels of acquisition of the same length, including a time vector.
Vectors as therefore synchronized (same index value corrispond to the same time instant for every array).
I display data on different figures (UIAxes) in my app figure.
To better and more easily use the application I would like the following to happen: each time the user hovers the cursor on any plot a vertical bar at the corrisponding x position of the cursor is displayed, on all the figures. All the figures display the same range of x values.
I also have a scatter figure with points from gps, still with the same length of the other arrays.
On that figure I'd really like to have, instead of the vertical line, a crosshair.
I've found this part of code here but I can't adapt it to App Designer and it's also pretty old.
Any kind of help is very welcome.
EDIT: Matlab Version 2020b
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.
Simplified Problem
I'm plotting 10 items.
To generate my plot I am creating 10 independent Line objects in a for loop
x=1:10;y=1;10;names = num2str((1:10)');
for i = 1:10
my_plots(i) = plot(x(i),y(i),'.','Color',rgb(i,:),'MarkerSize',14);
end
legend(my_plots,names);
When I click on an item in the legend it toggles visibility of the corresponding line
(legHandle.ItemHitFcn = toggleLegendItem).
function toggleLegendItem(src,evnt)
if strcmp(evnt.Peer.Visible,'on')
evnt.Peer.Visible = 'off';
else
evnt.Peer.Visible= 'on';
end
end
This works fine
I run into issues when some of my plots are actually the same category.
In this simple example, I could combine lines 1:5 into one object in a number of different ways, and pass the combined object to the legend as a single item in my_plots.
Actual problem
All of my line objects are distributed between several independent axes/subplots. Each axis has to remain independent because I need to be able to freely rotate each subplot without disturbing the other plots.
Progress so far
I've been able to build a shared legend between axes (because same class items share the same color, I only need to link the first line for each class), but I cannot figure out how to link multiple line objects to a single legend item, so that I am able to properly all lines across axes on each legend item callback.
I have an array of lines.
{{Line Line Line}}
{{Line Line Line}}
{{Line Line Line}}
...
{{Line Line Line}}
Basically what I need to do is set multiple Peer objects to a single legend item, but I am not sure if that is possible.
If someone has another solution that allows for combing multiple line handles across axes that would be helpful too.
So looking at the legend() function, I found that it's not possible to instantiate a legend with multiple Peer objects per item. There may be a way to go back and add multiple references via some sort of "combined object" but I'm not sure if a "combined object" exists that can handle objects with different Parent handles.
A quick fix to my problem (which was attributing a callback to the same item in multiple axes) was to use the shared properties within each class and across axes to get the handles for all items within each class. In this case I already assigned color to be distinctive between categories but a more objective property like Tag could also be used.
function toggleLegendItem(src,evnt)
% Find all items in this category
obj = findobj(findall(gcf,'type','Scatter'),'CData',evnt.Peer.CData);
for oid = 1:length(obj)
if strcmp(obj(oid).Visible,'on')
obj(oid).Visible = 'off';
else
obj(oid).Visible= 'on';
end
end
end
The one nuisance that this solution leaves is that the legend is a child of only one axis. If each category is not present in all axes, then the color for those missing categories may not show up. Luckily when you toggle each item's visibility the color appears and functions as normal. I would guess some other errors like this could occur.
I am completely new to Cognos, so sorry if I don't state some necessary information. I can't go into specifics about my chart, but here is the background:
I have a SQL code running into my Query
My chart and list use the same Query and have the exact same fields
My chart is a basic line graph
When I change my aggregate function to total for my y-axis, then I can see the data points
I do not want to use an aggregate function (I need to see all the points for my x and y-axis)
My x-axis is only one object, but it has multiple y-axis values within a year (which is my series). Ex:product-cost-year list,
where my product is the x-axis, cost is the y-axis, and series is year.
How can I get my chart to appear with all my data points? Eventually, I would like to add an upper and lower confidence interval to this chart.
One way to solve this issue is to create another column that simply counts the number of products (1,2,3,...9). We will call this column count. Keep all your fields the same (product for x-axis, cost for y-axis, and year for series). You will want to add count underneath product on the x-axis. You should see your mouse pointer turn to a horizontal line and it will place it under and to the right of product. Make sure not to place it just to the right of product.
In Matlab, I would like to visualize the test results in a figure with several charts and text. The figure is divided into rows and colums: 3 rows and 5 colums. For better understanding, here a screenshot of the figure with a orange grid which shows the subplot division:
Now I have several questions:
A) How can I include text into a specific section within the figure? i.e. test settings into subplot(6 and 11) and test results into subplot (7, 8, 9, 10).
B) Is it possible to "draw" separator lines between the subplots? i.e. to separate the test settings from the test result subplots for a better visualization.
C) Is it possible to set a title over several subplots such as "input data" and "output data"?
Thanks for your help!
Cheers,
Kevin
I have come this problem many times and haven't yet figured out a decent way to solve it. However what you can do is:
A) Include a Label (help label) in the subplot you want. Alternatively use a "edit locked" edit text field.
B) Yes in a way. Check out panels. Create a subplot, then inside a panel that fills the plot area. with the panel as parent create a figure (or label as in A) )
C) Thats a tricky one and I would use panels again, but I am not sure if that works.
These things are always a pain to do in Matlab itself. I usually ended up exporting my figures, writing a small HTML generator that places the images in divs and a decent CSS to make it look nice. It is way easier to do so if it is only for representing data. If you want it to be interactive you have to do it inside the UI.
Hope that helps
Benjamin