Colormap on polarhistogram bars

6 Ansichten (letzte 30 Tage)
MichailM
MichailM am 11 Feb. 2019
Beantwortet: Alok Nimrani am 19 Feb. 2019
Hi,
Is there any way to include a colormap on the polarhistogram bars? For example, based on the code below
close all;
clear all;
clc;
% Random theta values between 0 and 2*pi
a = 0;
b = 2*pi;
theta = (b-a).*rand(1000,1) + a;
% Random values between -100 and 100
c = -100;
d = 100;
val = (d-c).*rand(1000,1) + c;
data = [theta val];
% Plotting
f1 = figure(1);
p(1) = polarhistogram(data(:,1),...
'BinEdges',[deg2rad(0):deg2rad(15):deg2rad(360)],...
'Normalization','probability','FaceAlpha',1);
ax = gca;
ax.ThetaZeroLocation = 'top';
ax.ThetaDir = 'clockwise';
The polarhistogram is generaetd based on the values of the data(:,1) column. It would be useful to have a colormap based on the corresponding values of data(:,2).

Antworten (1)

Alok Nimrani
Alok Nimrani am 19 Feb. 2019
Hi Michail,
You can define a colormap using hsv function and then choose a line color according to the values of data(:,2). You can have a look at the following ML Answers post which describes an approach to achieve this: https://www.mathworks.com/matlabcentral/answers/91170-define-colormap-according-to-certain-variable
Hope this helps.

Kategorien

Mehr zu Colormaps finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by