フィルターのクリア

Scatter plot with categorical x axis

57 ビュー (過去 30 日間)
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2019 年 12 月 24 日
編集済み: dpb 2019 年 12 月 25 日
I need to produce scatter plot with categorical x axis.
I used this script:
figure(1)
x=['pixels'];
y=Tmean_split.pixels;
scatter(x,y)
in which the size of Tmean_split.pixels is 6*1.
I recieve this error:
Must supply X and Y data as first arguments.
Any idea why this error happening?

採用された回答

dpb
dpb 2019 年 12 月 24 日
編集済み: dpb 2019 年 12 月 24 日
'pixels' isn't an allowable argument for the x value position...it's a char() array string array and that's confusing the input parser inside scatter() -- it's trying to interpret the character string argument as one of the trailing optional arguments like the colorspec or the like, but as the documentation says, the x, y data have to be supplied before any of those.
scatter() also MUST have both x and y data arguments; you can't just give it a y vector like plot(). It will accept a categorical array as the X axis value, but you'll have to define it for the six categories to which each of the y variable values belongs to do so.
  2 件のコメント
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2019 年 12 月 25 日
What would be your solution? I need to have categorical value for X and nmerical value for Y showing the scatter values of the Ys.
dpb
dpb 2019 年 12 月 25 日
編集済み: dpb 2019 年 12 月 25 日
What are the categories? You've not shown what you want the x values to be. What part does the word 'pixels' play in things here?
x='pixels';
x=categorical(cellstr(x.'))
scatter(x,rand(size(x)),'filled')
yields
but I really doubt that's what you had in mind. But, as noted above, it does illustrate that scatter will accept a categorical x value, you just have to define what those are supposed to be...
Note by default order of the categorical array is alphabetic..

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by