Line plot in Grayscale

조회 수: 10 (최근 30일)
Gabriel Geyne
Gabriel Geyne 2013년 5월 29일
Hi,
I'm trying to create a line plot with 100 lines. The printout will be in black and white, so I would like to make the plots grayscale. I will be creating at least 50 plots, so I would like to avoid using the properties editor. The first line is to plot 1 unfiltered data, the second plot is the 100 points filtered data. The code for the plot looks like this:
plot(ADJTIME,SR,'k');hold on % Screw Rotation
plot(ADJTIME,FILTERED(:,1:100)); % Screw Rotation 100 Data Points Filtered
I would appreciate any help.

답변 (1개)

Image Analyst
Image Analyst 2013년 5월 29일
Perhaps you want to use the waterfall() function. Or do you want regular 2D lines plotted on a flat plot diagram like this:
SR = rand(1,100);
FILTERED = rand(50, 100);
ADJTIME = 1 : size(SR, 2);
plot(ADJTIME,SR,'k');
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
hold on % Screw Rotation
numberOfPlots = size(FILTERED, 1)
aRamp = linspace(0, 0.8, numberOfPlots);
for p = 1 : numberOfPlots
% Get the color for this line. Increasingly bright gray lines.
theColor = [aRamp(p), aRamp(p), aRamp(p)];
message = sprintf('That color = (%.3f, %.3f, %.3f)\n', theColor(1), theColor(2), theColor(3));
plot(ADJTIME,FILTERED(p,1:100), 'Color', theColor,...
'LineWidth', 4); % Screw Rotation 100 Data Points Filtered
promptMessage = sprintf('%s\nDo you want to Continue to plot another line,\nor Cancel to abort processing?',...
message);
titleBarCaption = 'Continue?';
button = questdlg(promptMessage, titleBarCaption, 'Continue', 'Cancel', 'Continue');
if strcmpi(button, 'Cancel')
return;
end
end
  댓글 수: 2
Gabriel Geyne
Gabriel Geyne 2013년 5월 30일
I need 2D plots. If I use the code provided, I do get different colors when plotted. I know that printing this in grayscale would do what I'm asking for, but I want to find a way to have the code print in grayscale. The figure below is the graph I obtain from:
plot(ADJTIME,FILTERED(:,1:100)); % Screw Rotation 100 Data Points Filtered
Image Analyst
Image Analyst 2013년 5월 30일
Code that who provided? Your code will plot with colors in the default color order. My code will plot the lines in grayscale. Did you actually try it and observer how it works??? Of course your hundred curves will look like a big gray mess so I'm not sure why you want that.

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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by