Can Matlab handle this color scheme?

According to the data that I attached I plotted and colored the plot manually in order that it looks funky like this:
Question is: Can Matlab copy this colordesign? I know Right, this isn't a GraphicDesignProgram, just want to check its limits.

7 comentarios

dpb
dpb el 18 de En. de 2021
No data attached...but that's pretty-much immaterial.
Unfortunately, line isn't into the 21st century yet with a variable color attribute but you could mimic a similar appearance in quite a number of ways...
Niklas Kurz
Niklas Kurz el 18 de En. de 2021
Yea, it's irrelevant that data can't be load.
It's More frightening that color control is pretty hard in MATLAB if it is to be a gradient.
dpb
dpb el 18 de En. de 2021
Well, what is the logic behind what was done there manually...
Adam Danz
Adam Danz el 18 de En. de 2021
Editada: Adam Danz el 18 de En. de 2021
Are you asking if that colormap can be created? Yes.
Are you asking about whether Matlab can plot smoothly transitioning gradients? Yes.
Color in the data you shared is clearly assigned according to the absolute value of y.
Niklas Kurz
Niklas Kurz el 19 de En. de 2021
that's a helpful documentation, thank you. Serarched an eternity for something like this
Adam Danz
Adam Danz el 19 de En. de 2021
If your data are finely sampled, you could use scatter() instead of a line.
Rik
Rik el 19 de En. de 2021
My first thought was to adapt something from the surf/patch family of functions.

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 19 de En. de 2021
See my answer here, where I vary the line color for two cases: along the y axis (which you want), and along the x axis.
clear all;
close all;
clc;
format long g;
format compact;
fontSize = 15;
fprintf('Beginning to run %s.m ...\n', mfilename);
x = linspace(0, 2*pi, 1000);
period = pi;
y = sin(2*pi*x/period);
numMarkers = numel(y);
markerColors = jet(numMarkers);
subplot(2, 1, 1);
for k = 1 : length(x)
plot(x(k), y(k), '.', 'Color', markerColors(k, :), 'MarkerSize', 30);
hold on;
end
grid on;
caption = sprintf('Line Color Varies Along X. Composed of %d Differently Colored Markers', numMarkers);
title(caption, 'FontSize', 20);
xlabel('x', 'FontSize', 20);
ylabel('y', 'FontSize', 20);
xlim([min(x), max(x)]);
% Maximize the figure window.
g = gcf;
g.WindowState = 'maximized';
% Do it again but instead of changing color as we move along the x axis,
% change it as we go along the y axis. So the marker color depends on the y value.
subplot(2, 1, 2);
numMarkers = numel(unique(y));
markerColors = jet(numMarkers);
miny = min(y);
maxy = max(y);
% Get indexes into the color map for each y value.
colorMapRows = round(rescale((y - miny) / (maxy - miny), 1, numMarkers));
for k = 1 : length(x)
thisMarkerColor = markerColors(colorMapRows(k), :);
plot(x(k), y(k), '.', 'Color', thisMarkerColor, 'MarkerSize', 30);
hold on;
end
grid on;
caption = sprintf('Line Color Varies With Y Value. Composed of %d Differently Colored Markers', numMarkers);
title(caption, 'FontSize', 20);
xlabel('x', 'FontSize', 20);
ylabel('y', 'FontSize', 20);
xlim([min(x), max(x)]);
fprintf('Done running %s.m.\n', mfilename);

1 comentario

dpb
dpb el 19 de En. de 2021
You can do something similar with scatter and the color vector.
It does seem like given the advances in computing and graphics/visualization TMW would have built a better mousetrap by now than having to resort to such workarounds at the user level.

Iniciar sesión para comentar.

Categorías

Productos

Preguntada:

el 18 de En. de 2021

Comentada:

Rik
el 19 de En. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by