Box plot function help

8 Ansichten (letzte 30 Tage)
Benjamin Wilson
Benjamin Wilson am 18 Feb. 2024
Bearbeitet: Adam Danz am 18 Feb. 2024
I am attempting to write a piece of code so that I can see a graph of the means and variances of different prices average sales using a pricing programme I have already written. I am struggling to get the box plots to print seperately rather than on top of eachother. Any help would be greatly appreciated.
  1 Kommentar
Adam Danz
Adam Danz am 18 Feb. 2024
Bearbeitet: Adam Danz am 18 Feb. 2024
> I am attempting to write a piece of code so that I can see a graph of the means and variances...
@Benjamin Wilson, note that boxplots depict the median and the upper and lower quartiles, not the mean and variance. Means and variances are usually only useful in normal distributions and in a perfectly normal distribution, the mean is the median. But if the distribution is non-normal or skewed, medians and quartiles may be more appropriate.
It sounds like you're plotting box plots on top of each other rather than using grouping variables. As William points out, we need more information to offer useful help. I'm not even sure if you're using boxplot or boxchart.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

William Rose
William Rose am 18 Feb. 2024
Others cannot run the code you supplied, since we don;t have singlepricingprogrammenew(), and I'm not suggesting you supply it. A better approach is to give the simplest example that runs and which illustrates the problem.
The problem is a lot of superimposed boxplots.
If you boxplot an array, you get a separeate boxplot for each column. Your function is attempting to do a separate boxplot for each row. You can transpose the array and get rid of the for loop.
x=randn(4,10000);
g={'Padres','Dodgers','Astros','Phillies'};
boxplot(x',g)
xlabel('Team')
Good luck.
  2 Kommentare
Benjamin Wilson
Benjamin Wilson am 18 Feb. 2024
I'm not sure I understand your response, I have provided the singlepricingprogrammenew as it is not a complicated peice of code:
William Rose
William Rose am 18 Feb. 2024
Perhaps someything is not woprking right on the attachment of code, or something is not working right on my end. Before, when I viewed your original post, there were about a dozen lines of code for a function, which included a for loop, and a call to singlepricing...() from within the loop. There were n attached files. Now you original post has one empty black line where code should be. And your most recent comment also has an empty black line, where code should be, and no attached files. Here is a screenshot of your original post as it appears now, for me:
At any rate, can you use my answer above to resolve your problem?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Specifying Target for Graphics Output finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by