Gradient Colour Fill plot points (more complex plot)
13 次查看(过去 30 天)
显示 更早的评论
Hi everyone,
I seem to be having a problem plotting gradient dots. I believe my issue is quite similar to the following previous posts and probably others:
I used the following code:
markerSize = 15;
t5=threshold5_table.store_temporal_tle.Percentage; % all of the following are 32x1, double, values between 0-1
t10=threshold10_table.store_temporal_tle.Percentage;
t15=threshold15_table.store_temporal_tle.Percentage;
t20=threshold20_table.store_temporal_tle.Percentage;
t25=threshold25_table.store_temporal_tle.Percentage;
t30=threshold30_table.store_temporal_tle.Percentage;
plot(ones(1, numel(t5)), t5, '.', 'MarkerSize', markerSize);
set(gcf,'Color','w') % set the background of figure to white
hold on
plot(2 * ones(1, numel(t10)), t10, '.', 'MarkerSize', markerSize);
hold on
plot(3 * ones(1, numel(t15)), t15, '.', 'MarkerSize', markerSize);
hold on
plot(4 * ones(1, numel(t20)), t20, '.', 'MarkerSize', markerSize);
hold on
plot(5 * ones(1, numel(t25)), t25, '.', 'MarkerSize', markerSize);
hold on
plot(6 * ones(1, numel(t30)), t30, '.', 'MarkerSize', markerSize);
xlim([0 7])
ylim([0 1])
set(gca, 'XTick', [1 2 3 4 5 6], 'xTickLabel', {'5%','10%','15%','20%','25%','30%'},'FontSize',14,'FontWeight','bold');
...to plot the data:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1153478/image.png)
My issue: I want to adjust the colour of the scatter 'filled' dots to reflect the amount of entries with the same scores, ie, in the first 5% plot, there are: 7 entries (0), 6 entries (1) and values between (0-1) are mostly single entries, but the colour doesnt show that. To keep things simple I'd like to plot all percentages in same colour (with gradient), if possible.
The example provided here https://uk.mathworks.com/help/matlab/ref/scatter.html (under opacity) seems quite similar. However, opacity is refering to the distance from zero. Im interested in the proportion of entries.
I believe I need to design a colormap? and then refer to the saved colormap here, in place of '???', but everything i've tried so far doesnt work with my code.
plot(ones(1, numel(t5)), t5, '.', 'MarkerSize', markerSize, 'Color', ???);
Any suggestions?
Thank you!
Vyte
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Colormaps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!