matlab: bar, how to change the edge color? - matlab

I am having trouble to change the bar color, I want it to be white in the middle, and red at the edge. Looking at matlab's description
if I do:
bar(y,'FaceColor','w','EdgeColor','r','LineWidth',1)
It should give me the above. However, when I actually run it, it only give me white graph.
Update: my y is:
y=zeros(1,5000); y(3000)=1; y(4000)=1;
Using the above, I got....

With so many bars, Matlab probably has trouble differentiating edge ('EdgeColor') and fill ('FaceColor') of each. After all, each complete bar is less than a screen pixel.
I suggest you use white edge and colored fill. That works for me. It's as if 'FaceColor' had precedence over 'EdgeColor'.
bar(y,'FaceColor','r','EdgeColor','w','LineWidth',1)
Or better yet: replace each bar by a line, that is, use stem:
stem(y,'r','marker','none')

Related

Draw a line and color it based on direction

Is it possible to draw a line similar to the example below and color it based on the previous value?
So to have the color red when the line is moving down and green when it goes up.
Can this be done with line type? Or does it need to be drawn with markLine or something else?
Any help is much appreciated!
https://echarts.apache.org/examples/en/editor.html?c=dynamic-data2
I don't think it is possible with the line chart, as the whole line uses the same color for all points. I suggest you use a scatter type chart where each point can have a different color. By setting symbol size to a small value and drawing values close together you can emulate visual line.
Here is an example based on the regression sample from echarts site:

If I have 4 coordinates making a rectangle, how can I color in that area?

I have 4 coordinates assigned to variables, so I would just like to colour in the rectangle that is created from these variables. I tried the fill function, but I cant gather much information from the example.
When I try to use:
fill(bottom left point, top right point,'g')
the figure it makes only shows a line between those points, and doesn't colour in the entire area.
I'm using MATLAB R2019b, if that helps.
Also, if its possible to fill the rectangle with a pattern instead, please let me know aswell.
Thanks in advance

Matlab Increase thickness of lines of 3d bars

I have a 3D bar chart. Let me clarify, I do not want to edit the width of the bar graph as I have already done that. However, there are black lines that outline each bar. Is there a way to make these thicker?
Everything I have search pays reference to the width of the bars themselves, not the black lines enclosing them.
At last, I found the answer to my own question the minute after I ask it.
Simply:
set(j,'LineWidth',1.5)
EDIT: As Luis mentioned, j is the handle such that j = bar3(...)
Sorry should have included that.

How to change the histogram colour in Matlab

So i'm awful at Matlab and I mainly learn through examples and literally spelt out explanations.
So baring that in mind - Right now i'm trying to find how likely it is that one image i'm given is in anther via a histogram.
What i want to do is create 3 histograms for red, blue & green for each image and then add those into one image - So basically i'll have an image with a literal green histogram showing the green, a red one showing the red and a blue one showing the blue.
I know that to show a colour chanel in matlab i have to do imhist(image(:,:,1/2/3)
however that still gives me a histogram in blue.
I've looked up some things that are meant to help with this issue but it's normally aimed toward someone who knows what they're doing.... not helpful.
I've heard peope saying something like get(get(gca,'child')) which just seems giberish to me.
SO - for what i'm trying to do, image detection via histrograms, is this an appropriate method? And if so HOW do i create my 1 histogram that shows all 3 histograms in their respective colour
Cheers
You could use this version of imhist:
[counts,x] = imhist(...)
And then draw your histograms yourself, via bar, stem or similar.
These functions are then fully customizable and you can plug in your favourite color, linestyle, etc.

how to make stacked bar graph readable in white and black only

I have a stacked bar graph to include in my paper, which is going to be printed by reviewers in black and white only. When I print it out, I cannot tell the difference between some parts of it, which would otherwise be clearly distinguishable in color. Is there any way to make it readable even in black and white? Thanks in advance.
Have a look at the function presented in this File Exchange Pick of the Week to create hatched patterns instead of (or in addition to) your colors.
Here's one example:
Here's one example of how to use applyhatch_pluscolor:
figure, bar(rand(3,4)
[im_hatch,colorlist] = applyhatch_pluscolor(1,'|-.x',1,[1 0 1 1]);