Line plot in Grayscale
40 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Image Analyst
on 29 May 2013
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 Comments
Image Analyst
on 30 May 2013
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.
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!