Line plot in Grayscale
10 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
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 个评论
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
