matlab create title for each boxplot - matlab

Here is a problem:
I have a boxplot but there is no easy way to name each of these small boxes.
Here is an example:
boxplot(rand(10,3))
will draw 3 of this boxes, but will the title for each of these boxes are 1, 2, 3 and I need some more meaningful things.
I have one idea, how to achieve it,
load carsmall
boxplot(MPG,Origin)
But this require to restructure my data and create additional columns with titles.

Does
boxplot(rand(10,3), 'labels', {'a','b','c'})
do what you need?

Related

Tableau Legend Issue

I'm trying to use a legend(which is common for more than 2 columns)
such that
a. tick mark means 3
b. exclamation mark means 2
c. Bold circle means 1
See the screenshot for 2 columns displayed in the attachment.
However i need a common legend for these columns
I tried to go to analysis tab and then click on legends, but this will show legend for only 1 column at a time and i need 1 legend for more than 2 columns.
In general, if the customization and formatting options for the built-in legends and filter controls don't do as you wish, the next approach is to build a worksheet that shows and acts as you desire. Then use that worksheet on your dashboard to serve a replacement for the built-in legends.
In your case, one approach is to make a simple text data source with one row for each item you want to appear in your new custom "legend". Then build the legend worksheet of your dreams :-)

Matlab figure visualization

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

produce several maps in same figure window in matlab

I would like to generate a figure in matlab which looks like the attached .jpeg:
So, the figure should contain an outline of the world and then 3 other figures looking at the USA, UK, and New Zealand where I can then specify individual locations in each country. How would I achieve this?
Subplots to arrange things, images to create the maps, and lines to connect them to points. To create a complicated subplot structure like that I'd suggest you check out Ben Mitch's panel class. The relevant thing you're looking for is its ability to conveniently divide up and manage subplots. Something like this
p = panel('defer');
p.pack('v', [1/5 3/5 1/5]);
p(1).pack('h',[1/5 2/5 2/5]); % top level, US and New Zealand
p(2).pack('h',[1/5 2/5 2/5]); % mid level
p(3).pack('h',[1/5 3/5 1/5]); % bottom level
p(2,2).select();
image(world_image);
p(1,3).select();
image(new_zealand_image);
p(1,3).select();
image(usa_image);
p(1,1).select();
image(uk_iamge);
Then add a few line commands to show where the submaps link to. Note that I haven't gotten a chance to test the above code yet, but will when I get to work. I can't remember offhand if it likes the 'h' argument within the child panels.

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 !

How to draw several graphics in one picture in Mathematica?

Just like hold on in Matlab.
I met this problem when i want to draw several lines in one picture.
The number of lines varies.
Mathematica has a lot of constructs allowing you to combine plots, graphics and images.
I'll give you several examples. You can search the help system to find out more and understand the subtleties of the examples bellow:
Edit
If you want to read/write from/to files, the following code may serve you as a starting guide:
(*Create data*)
data = RandomReal[1, {8, 2}];
(*Put into a file*)
Export["c:\\test.tab", data, "Table"];
(*Read the file into another list*)
rdat = Import["c:\\test.tab", "Table"];
(*And Plot it like before*)
Graphics[{Line##, Red, PointSize[Large], Point /# #} &#rdat]
Mathematica 8 introduced a new versatile function Overlay, which can be used to graphically overlay any type of expression:
Overlay[{Graphics[{Yellow, Disk[]}], "Sun"}]
Use Show to combine graphics objects.
Show[Plot[Sin[x],{x,0,10}], Plot[Cos[x],{x,0,10}]]
EDIT If you want to draw several lines, then build your Graphics object out of several lines:
Graphics[ Table[ Line[{{0,0}, {Cos[x],Sin[x]}}], {x,0,Pi,Pi/10} ] ]
combine graphics primitives like Szabolcs said:
Graphics[ Table[ Line[{{0,0}, {Cos[x],Sin[x]}}], {x,0,Pi,Pi/10} ] ]
but if you are using plot then what you need to do is:
Show[Table[Plot[A Sin[x],{x,0,2 Pi}],{A,0.1,10}]]
Show command allows you to combine the graphics Table produces varying A, each one of them a Plot over x.