Can you use an image for a histogram bar

3 views (last 30 days)
Joshua Sayre
Joshua Sayre on 13 Feb 2015
Answered: Image Analyst on 14 Feb 2015
Hey I am a student using matlab and was wondering if there was a way to change the facecolor of a bar in the histogram to an image. I am able to change the color; however, I cannot get it to load a image on the bar. Below is the code I am using. When I do this it does not read the image file and reads an error.
% importing
care = xlsread ('Caregivers.xlsx'); %imports the excel doc as a variable
% Histogram
% known variables
age = care(1:100,2);
% making age histograms
[n1,x1] = hist(age);
final_age = bar(x1,n1,.99);
set(final_age,'facecolor','google.png')
title('Caregiver Ages')
xlabel('Ages')
ylabel('Frequency')
grid
  1 Comment
Geoff Hayes
Geoff Hayes on 14 Feb 2015
Joshua - if the error message is
Error using specgraph.colorevent/set
RGB Color must be a 3 element numeric vector.
then that suggests that the only input for the 'facecolor' property is something of the form [0 1 0]. Why are you trying to "paste" an image onto your bar plot?

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 14 Feb 2015
I don't think so. You'd have to display the image and then draw the bar outlines with plot() or line().

Tags

Community Treasure Hunt

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

Start Hunting!