
If you are still having trouble after trying those fixes, you could try setting the color using indexed color mapping instead, as illustrated in one of my other answers (near the bottom). This shadows the built-in min and max functions, which can also lead to the same error message under other conditions. Incidentally, you should also not be giving your variables the same name as existing functions, like you are doing here.
#Matlab 2017 colormap for bar graph update
get and set) instead of dot notation to update the property: cData = get(h, 'CData') You could also try using function notation (i.e. I would double-check how you are computing color_map_index. the value for color_map_index is less than 1). How can i set the bars following one specific colormap. giving different colors to the individual bars using colormap function, but instead I get the same color for all bars.
#Matlab 2017 colormap for bar graph how to
It's more likely that your error is coming from the line above it (i.e. MATLAB: How to use colormap for different bars. Since we know n is a positive integer greater than or equal to one, the indexing here shouldn't have a problem. I got started by referencing this post on Matlab central, which used 'function handles' to pass plotting. A rainbow colormap is based on the order of colors in the spectrum of visible light. This week I want to explain some of the motivations for replacing jet. Parula has replaced jet as the default colormap in R2014b, which was released earlier this month. What's going on here? Both new_edge and N are 1圆5 vectors.Īre you certain that the error you're getting ("Subscript indices must either be real positive integers or logicals") is coming from the following line?: h.CData(n,:) = rbg I needed to make a plot that superimposes a 'stacked' bar graph with a line in Matlab. Last week I showed you the new MATLAB colormap, parula. If I dive into the h object, MATLAB tells me that CData has a size of (4圆5). Subscript indices must either be real positive integers or logicals. I get the following error when I try to apply the color: I do this by creating a colormap with # of bins and a min/max, getting a color index, then finally retrieving the rbg value. Next, I want to loop through and prescribe the color for each bar based on a calculation. Similar to the MATLAB example, I first create my bar graph. Here is my code: h = bar(new_edge,N,'hist','FaceColor','flat') CData, described here seems to do what I want but I can't get it to work. Additionally, I would like to color the individual bars as a function of the x axis location. I have a collection of data that I am trying to graph as a histogram.
