Making points transparents [duplicate] - matlab

This question already has answers here:
Plot circles with alpha values in MATLAB
(5 answers)
Closed 8 years ago.
I have a plot similar to the one below. This is a cylindar. The points near the axis are red and become more and more blue when they get far from it.
The problem is that the blue points completely hide the red ones.
Is there any way to make these blue points transparent enough to see what's inside?

I could suggest a hack to try. Given that you approximately know what the colors of the points you want to remove are, you could use findall or findobj to extract the line objects from your plots (maybe they're named something else in a 3D plot, don't have a lot of experience there) and then just delete those with the blue coloration.

Related

I want to prevent the plot line from hanging over the axis in MATLAB [duplicate]

This question already has an answer here:
How to hide the lines of a graph in MATLAB so that they do not extend beyond the frame
(1 answer)
Closed 1 year ago.
As you can see in the attached image, the line of the graph hangs over the axis, how can I make it not hang over the axis?
A simple approach could be to call something like
ylim([min(y(:))-0.02*range(y(:)) Inf]);
after plotting your data y. The 2% margin may be adjusted to your tastes.

How can I create a colormap with many visually distinct colors? [duplicate]

This question already has answers here:
Matlab choose random color for plotting
(2 answers)
Closed 6 years ago.
Difference from proposed duplicate
Matlab choose random color for plotting asks how to create a colormap with randomly selected colors. I am asking how to choose visually distinct colors for a colormap. Randomly selected colors are not guaranteed to be visually distinctive. In fact, I use random colors as a counter example in my question.
If my question is going to be a duplicate, it should be a duplicate of Automatically plot different colored lines because at least one of the answers, answers my question about visually distinct colors even though the question does not ask for that detail. But none of the answers of Matlab choose random color for plotting are helpful, so don't use that one!
Original Question
The lines colormap alternates 7 colors that are visually distinct in a predefined order. flag and prism do this also. The colors repeat after 7 distinct colors for lines, 6 for prism and 4 for flag.
These colormaps are very useful for distinguishing between labeled segments in an image because labels often have consecutive values which have low visual distinctness in the jet or parula colorspaces.
For example, using the first image from the NYUv2 dataset, you can see that dishwasher and counter have almost the same color using colormap('parula')
It gets better for dishwasher and counter using colormap('lines'), but worse for chair and trashcan, because the value of trashcan is 12 and chair is 5. 12 mod 7 = 5, so they get the same color assignment
I have n labels, so I would like to define a colormap that has n alternating visually distinct colors. Then, I can avoid the problem of two labels sharing the same modulus.
I know how to create a custom colormap, but the challenge is making the colors visually distinct. One thing I tried is randomly sampling colors from jet (similar to the solutions suggested to Matlab choose random color for plotting).
c_jet = colormap('jet');
idx = randperm(size(c_jet, 1));
c_new = c_jet(idx(1:30),:);
colormap(c_new);
But the colors are not visually distinct enough. The ceiling and the wall are practically identical.
It may be the case that 30 distinct colors is simply too many to ask for, but I'd like a general approach that gets as close as possible.
For example from wikipedia you can get a list of distinguishable colors
Help:Distinguishable colors
The references contain a link to a stackexchange thread where you can read more.
With theses colors you can build your own colormap.

how to create 3d cylinder matlab [duplicate]

This question already has answers here:
Cylinder with filled top and bottom in matlab
(2 answers)
Closed 7 years ago.
I am trying to create a filled 3d shape that will look similar to this: (long round object)
(no need for the round part at the top, one color for all the object is good)
I've tried to create many similar circles with different center point but it didn't work, and with cylinder all I got was weird shapes.
To make a cylinder the exact name exists as a command:
figure;
cylinder(0.1,20);
axis equal;

Getting values from axis on mouse click [duplicate]

This question already has answers here:
Retrieving X and Y values from Matlab Plot
(4 answers)
Closed 9 years ago.
I'm developing a GUI in Matlab that presents a plot (in an axis object). When clicking on a point in the plot, the GUI will open some other plots for that data point.
I added an axis object to my figure and implement the WindowButtonDownFcn to get a button click. I can get the mouse position with
pos=get(hObject,'CurrentPoint');
but how do I convert it to values in my plot? (i.e. which x-value was clicked on)
thanks.
(I'd be happy to hear if there is some simpler way to do this, instead of writing my own GUI)
Try looking up the help on ginput and then set that to some variable. Then plot the points for the number of ginputs you've done.
A lot of it is explained here: http://www.mathworks.com/help/techdoc/ref/ginput.html

Moving a point along a curve in matlab [duplicate]

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Points moving along a curve within MATLAB
I have two arrays ,the first represents the x-axis values and the second represents the y-axis values of a certain curve. I want to draw a point (or some object) that moves along that curve in MATLAB.
You can just trace the curve, i.e., you can place the cyrsor on the curve and press left or right to move your cursor across it.