Same colour scale for scatter and line plots on same graph - different groups of data

I have 2 sets of data (denoted by 250 and nothing at the end of the string)
My 2 problems:
  1. I'm trying to make line plots through the datapoints which are the same colour as the scatter markers, how can I do this?
  2. I want to make the colour scale for '250' and nothing data to be along different colour scales - like red and green colours of different darkness level if that is possible! Does anyone know how to do this? I've attached the code I have so far with this goal in mind
Cheers!!
powerpc=[70 58 42 28];
figure
%subplot(4,2,8);
scatter(powerpc,abs(table2array(inner70mw03))',20)
hold on
scatter(powerpc,abs(table2array(inner70mw05))',20)
hold on
scatter(powerpc,abs(table2array(inner70mw07))',20)
hold on
scatter(powerpc,abs(table2array(inner70mw09))',20)
hold on
scatter(powerpc,abs(table2array(inner70mw03_250Hz))',20)
hold on
scatter(powerpc,abs(table2array(inner70mw05_250Hz))',20)
hold on
scatter(powerpc,abs(table2array(inner70mw07_250Hz))',20)
hold on
scatter(powerpc,abs(table2array(inner70mw09_250Hz))',20)
ylabel('Carbonised region diameter/ \mum');
xlabel({'Laser Power/mW'})
M=8;
% pick some colormap and apply it to the colororder property
mycolortable = parula(M);
%set(powerpc,'ylim',[0 5])
ylim([0 25])
xlim([20 70])
set(gca,'colororder',mycolortable)

 採用された回答

Star Strider
Star Strider 2022 年 3 月 8 日

0 投票

For 1. this is easy enough
Use plot instead of scatter —
powerpc=[70 58 42 28];
figure
%subplot(4,2,8);
plot(powerpc,abs(table2array(inner70mw03))', '-o')%, 'MarkerSize',20)
hold on
plot(powerpc,abs(table2array(inner70mw05))', '-o')
hold on
plot(powerpc,abs(table2array(inner70mw07))', '-o')
hold on
plot(powerpc,abs(table2array(inner70mw09))', '-o')
hold on
plot(powerpc,abs(table2array(inner70mw03_250Hz))', '-o')
hold on
plot(powerpc,abs(table2array(inner70mw05_250Hz))', '-o')
hold on
plot(powerpc,abs(table2array(inner70mw07_250Hz))', '-o')
hold on
scatter(powerpc,abs(table2array(inner70mw09_250Hz))', '-o')
ylabel('Carbonised region diameter/ \mum');
xlabel({'Laser Power/mW'})
M=8;
% pick some colormap and apply it to the colororder property
mycolortable = parula(M);
%set(powerpc,'ylim',[0 5])
ylim([0 25])
xlim([20 70])
set(gca,'colororder',mycolortable)
I do not understand what you want for 2.
.

4 件のコメント

Em
Em 2022 年 3 月 8 日
Thanks so much!
For part 2 I'm trying to get those plots with 250 in the name and those without the 250 to be on a different colour scale -- so like
plot(powerpc,abs(table2array(inner70mw03))', '-o')%, 'MarkerSize',20)
hold on
plot(powerpc,abs(table2array(inner70mw05))', '-o')
hold on
plot(powerpc,abs(table2array(inner70mw07))', '-o')
hold on
plot(powerpc,abs(table2array(inner70mw09))', '-o')
on a scale of light red to dark red
then
plot(powerpc,abs(table2array(inner70mw03_250Hz))', '-o')
hold on
plot(powerpc,abs(table2array(inner70mw05_250Hz))', '-o')
hold on
plot(powerpc,abs(table2array(inner70mw07_250Hz))', '-o')
hold on
scatter(powerpc,abs(table2array(inner70mw09_250Hz))', '-o')
on a scale of light green to dark green
I'm trying to use colour to show one parameter (250 or not) and darkness to show the scale of another parameter.
Do you know how this could be done?
Star Strider
Star Strider 2022 年 3 月 8 日
As always, my pleasure!
This is the best I can do for the colours —
load('frequencywidth.mat');
cmr = colormap(hot(12));
cmg = colormap(summer(12));
powerpc=[70 58 42 28];
figure
%subplot(4,2,8);
plot(powerpc,abs(table2array(inner70mw03))', '-o', 'Color',cmr(1,:))
hold on
plot(powerpc,abs(table2array(inner70mw05))', '-o', 'Color',cmr(2,:))
hold on
plot(powerpc,abs(table2array(inner70mw07))', '-o', 'Color',cmr(3,:))
hold on
plot(powerpc,abs(table2array(inner70mw09))', '-o', 'Color',cmr(4,:))
hold on
plot(powerpc,abs(table2array(inner70mw03_250Hz))', '-o', 'Color',cmg(1,:))
hold on
plot(powerpc,abs(table2array(inner70mw05_250Hz))', '-o', 'Color',cmg(2,:))
hold on
plot(powerpc,abs(table2array(inner70mw07_250Hz))', '-o', 'Color',cmg(3,:))
hold on
plot(powerpc,abs(table2array(inner70mw09_250Hz))', '-o', 'Color',cmg(4,:))
ylabel('Carbonised region diameter/ \mum');
xlabel({'Laser Power/mW'})
% M=8;
% pick some colormap and apply it to the colororder property
% mycolortable = parula(M);
%set(powerpc,'ylim',[0 5])
ylim([0 25])
xlim([20 70])
% set(gca,'colororder',mycolortable)
Experiment with that to get the result you want, since it may be necessary to subscript into different rows of the red (‘cmr’) and green (‘cmg’) arrays to do that. Using colororder is a bit difficult here.
.
Em
Em 2022 年 3 月 9 日
Thanks so much! That's exactly what I was looking for.
Star Strider
Star Strider 2022 年 3 月 9 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Discrete Data Plots についてさらに検索

製品

リリース

R2021b

質問済み:

Em
2022 年 3 月 8 日

コメント済み:

2022 年 3 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by