MATLAB: Help with desired color in patch command?

  • MATLAB
  • Thread starter hivesaeed4
  • Start date
  • Tags
    Color Matlab
In summary, the person is having trouble getting the patch command to create a black color for their boundary wall in their MATLAB project, despite following the instructions in the help section. They have attached screenshots of their code and the resulting wall, and someone has pointed out that they set the color to red instead of black. They are still seeking assistance in achieving their desired color.
  • #1
hivesaeed4
217
0
Hi,
I'm trying to make a boundary wall using the patch command for a project. Trouble is while the boundary wall is alright, it's color is'nt what I desired and for some reason the patch command is'nt following the rgb color chart despite what the help on MATLAB says. I want it to be black. Could someone tell me what mistake I'm making in my code, and tell me how to get any desired color using the patch command?

Attsached are the screen shots of my code as well as the resulting boundary wall.
 

Attachments

  • code.jpg
    code.jpg
    22.4 KB · Views: 463
  • resulting boundary wall.jpg
    resulting boundary wall.jpg
    28.6 KB · Views: 527
Physics news on Phys.org
  • #2
Not sure if you figured out your problem yet, but you set the color to red instead of black

[1 0 0] = Red
[0 0 0] = Black
 

1. What is the syntax for specifying a desired color in the patch command?

The syntax for specifying a desired color in the patch command is as follows:

patch(x, y, 'color')

Where 'color' can be specified using a color name, RGB triplet, or hexadecimal code.

2. Can I use a custom color in the patch command?

Yes, you can use a custom color in the patch command by specifying an RGB triplet or hexadecimal code. For example:

patch(x, y, [0.5, 0.2, 0.8])

This will create a patch with a custom color that is a mix of red, green, and blue.

3. How do I change the transparency of the patch in MATLAB?

To change the transparency of a patch in MATLAB, you can use the 'FaceAlpha' parameter. For example:

patch(x, y, 'FaceAlpha', 0.5)

This will make the patch 50% transparent.

4. Can I create a gradient color in the patch command?

Yes, you can create a gradient color in the patch command by using the 'FaceColor' parameter and specifying a color name followed by a colon and a second color name. For example:

patch(x, y, 'FaceColor', 'blue:red')

This will create a gradient color that starts with blue and ends with red.

5. How can I change the color of the border in a patch in MATLAB?

To change the color of the border in a patch in MATLAB, you can use the 'EdgeColor' parameter. For example:

patch(x, y, 'EdgeColor', 'green')

This will make the border of the patch green. You can also use RGB triplets or hexadecimal codes to specify a custom color for the border.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
802
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
8K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
956
  • Computing and Technology
Replies
3
Views
2K
Back
Top