Why doesn't the color vector work here?

조회 수: 3 (최근 30일)
Ricardo Boza Villar
Ricardo Boza Villar 2016년 3월 16일
댓글: Ricardo Boza Villar 2016년 3월 17일
I'm plotting a math function with a customized grid, but the color of the latter is black, whereas I've defined it as grey. Why does this happen and how can I fix it?
% Gráfica de Mecánica de Fluidos
function []=a3(gamma)
figure(1), close(1),figure(1)
% Llamo quo a A(s)/Amin
M=0:0.01:6;
num=(1+(gamma-1)/2)^(-(gamma+1)/(2*(gamma-1)));
den=M.*(1+(gamma-1).*M.^2/2).^(-(gamma+1)/(2*(gamma-1)));
quo=num./den;
g_x=0:1/4:6; % grid
g_y=0:1:60; % grid
grey=[1 1 1]*0.4; % grid colour
for k=1:length(g_x)
plot([g_x(k), g_x(k)], [g_y(1), g_y(end)],'color',grey)
hold on
end
for k=1:length(g_y)
plot([g_x(1), g_x(end)], [g_y(k), g_y(k)],'color',grey)
hold on
end
plot(M,quo,'r')
title('Cociente de áreas frente al Mach')
xlabel('M(s)')
ylabel('A(s)/Amin')
%

채택된 답변

Ced
Ced 2016년 3월 16일
Try
grey=[1 1 1]*0.8; % grid colour
  댓글 수: 1
Ricardo Boza Villar
Ricardo Boza Villar 2016년 3월 16일
I don't know why but I kept reducing that coefficient on and on instead of increasing it. Thank you :)

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Image Analyst
Image Analyst 2016년 3월 16일
Looks gray to me. The grid lines are definitely not as dark as the black title. If you want you could try line() instead of plot(). With one pixel wide lines, you might have an aliasing problem so the colors might not be what you expect.
  댓글 수: 1
Ricardo Boza Villar
Ricardo Boza Villar 2016년 3월 17일
편집: Ricardo Boza Villar 2016년 3월 17일
I'm a beginner, but I'll look into it.
By the way, there might be some expressions I write which sound odd, but English isn't my native tongue, so... sorry for that!

댓글을 달려면 로그인하십시오.


Ricardo Boza Villar
Ricardo Boza Villar 2016년 3월 17일
Thank you both for your answers. The problem is solved, but I'd like to ask something else. Is it me or when I have several parallel lines it looks as if there were some lines which are very well defined (as if they met a line of pixels), and some other lines which aren't (they don't have as good definition as the others). What is responsible for this, the archive format or my computer screen? And why?
  댓글 수: 2
Image Analyst
Image Analyst 2016년 3월 17일
It could be due to anti-aliasing. What if grid line #1 was supposed to be at line #101 on your monitor, and grid line #2 was supposed to be at line #143.5 on your monitor. But there is no line #143.5, so line 143 gets half a line and line 144 gets half a line, which means the grid line is split over two monitor lines and each line is half as dark (twice as bright), so the line looks fainter instead of being a nice solid dark line like the line that landed exactly at line #101.
Ricardo Boza Villar
Ricardo Boza Villar 2016년 3월 17일
Thank you!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by