I would like to modidy the colors in this 2d plot, different from standard ones (e.g., 'b', 'k')
조회 수: 2 (최근 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
댓글 수: 0
채택된 답변
Antoni Garcia-Herreros
2023년 4월 3일
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)
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
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
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);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Scatter Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!