[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting plots in Octave to show colors like Matlab.

From: Hartmut
Subject: Re: Getting plots in Octave to show colors like Matlab.
Date: Sun, 23 Apr 2017 11:33:35 -0700 (PDT)

The CData property doesn't seem to be implemented in the Octave version of
the bar command.

You could work around this by plotting all the single bars individually. And
setting an individualy color of each individual bar. The following code runs
for several seconds, but works generally fine for me (in Octave 4.2.1):

--- code ----
pkg load image
rgbImage = imread('marbles.jpg');  % Load image Image of marbles.jpg:
hsvImage = rgb2hsv(rgbImage);         % Convert the image to HSV space
hPlane = 360.*hsvImage(:, :, 1);      % Get the hue plane scaled from 0 to
binEdges = 0:360;                 %# Edges of histogram bins
N = histc(hPlane(:),binEdges);    %# Bin the pixel hues from above

C = colormap(hsv(360));  %# create an HSV color map with 360 points
stepsize = 10; % stepsize 1 runs for a while...

for n=binEdges(2:stepsize:end)   %# Plot the histogram, one bar each
    if (n==1), hold on, end
    set(h,'FaceColor',C(n,:));   %# set the bar color individually

axis([0 360 0 max(N)]);           %# Change the axes limits
set(gca,'Color','k');             %# Change the axes background color
set(gcf,'Pos',[50 400 560 200]);  %# Change the figure size
xlabel('HSV hue (in degrees)');   %# Add an x label
ylabel('Bin counts');             %# Add a y label
--- code ---

By the way, Matlab seems to also have the same problems, when using a Matlab
version of 2014b or newer, see [1]

I hope this helps.



View this message in context:
Sent from the Octave - General mailing list archive at

reply via email to

[Prev in Thread] Current Thread [Next in Thread]