I would like to modidy the colors in this 2d plot, different from standard ones (e.g., 'b', 'k')

3 次查看(过去 30 天)
T1 = readtable('variazione.xlsx', 'VariableNamingRule','preserve')
figure
plot(T1.('X'), T1.('S'), '-r',T1.('X_1'), T1.('S_1'), '-b',T1.('X_2'), T1.('S_2'), '-k', 'Linewidth', 1.3)
grid
xlim([-10 10])
ylim([0 25])
set(gca,'xticklabel',num2str(get(gca,'xtick')','%.0f'))
L=legend('E=x MPa','E=y MPa','E=z MPa', 'Location','northwest');
set(L,'Interpreter','latex')
set(gca,'TickLabelInterpreter','latex')
xlabel('$x$ [mm]', 'Interpreter','latex');
ylabel('$\tau$ [Pa]', 'Interpreter','latex');
I would like to choose #D95319 and #A2142F and #77AC30 for the three differend plots

采纳的回答

Antoni Garcia-Herreros
Hello,
You could separate the plot and specify the colors individually.
D95319=[217,83,25]/255;
A2142=[162, 20, 47]/255;
AC30=[119, 172, 48]/255;
plot(T1.('X'), T1.('S'), 'Color',D95319, 'Linewidth', 1.3)
Unable to resolve the name 'T1.X'.
hold on
plot(T1.('X_1'), T1.('S_1'), 'Color',A2142, 'Linewidth', 1.3)
plot(T1.('X_2'), T1.('S_2'), 'Color',AC30, 'Linewidth', 1.3)
  1 个评论
Dyuman Joshi
Dyuman Joshi 2023-4-3
You can directly use the color code OP mentioned -
x=0:0.01:10;
plot(x, sin(x), 'Color', '#D95319')
hold on
plot(x, cos(x), 'Color', '#A2142F')
plot(x, sin(x).*cos(x), 'Color', "#77AC30")
ylim([-1.75 1.75])
legend({'sin', 'cos', 'sin*cos'})

请先登录,再进行评论。

更多回答(1 个)

Image Analyst
Image Analyst 2023-4-3
You can define your own colors. For example if you wanted an RGB of 40, 50, 90, you can do
plot(T1.('X'), T1.('S'), '-', 'Color', [40, 50, 90]/255);
or
darkBrown = [120, 50, 20] / 255;
plot(x, y, '-', 'Color', darkBrown);

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by