Plot graph of different color for different points? Matlab

In summary, to plot a graph with different colors for different points in Matlab, you can use the "scatter" function and specify a vector of color values or use a colormap. You can also customize the colors used in the plot graph by using the "colormap" function. To create a legend for the plot graph, you can use the "legend" function and customize its appearance. Additionally, you can change the shape and size of the points in the graph using the "scatter" function. To add a title, labels, and colorbar to the graph, you can use the "title", "xlabel", "ylabel", and "colorbar" functions.
  • #1
cks
165
0
I would like to plot a curve with each point with different color.

For example

x0=2;
for i=1:1:200
x1=x0*cos(x0)+exp(x0);
plot(i,x1) (THIS IS THE PLACE WHERE I WANT TO PUT DIFFERENT COLOR)
x0=x1;
end
 
Physics news on Phys.org
  • #2
scatter(1:10,2:11,50,jet(10))
 

Related to Plot graph of different color for different points? Matlab

1. How do I plot a graph with different colors for different points in Matlab?

To plot a graph with different colors for different points in Matlab, you can use the "scatter" function. This function allows you to specify a different color for each point by passing in a vector of color values or using a colormap. You can also use the "hold on" command to plot multiple scatter plots with different colors on the same graph.

2. Can I customize the colors used in the plot graph in Matlab?

Yes, you can customize the colors used in the plot graph in Matlab. You can specify the color for each point individually or use a colormap to assign colors based on the data values. You can also change the default color scheme in Matlab by using the "colormap" function.

3. How do I create a legend for a plot graph with different colors in Matlab?

To create a legend for a plot graph with different colors in Matlab, you can use the "legend" function. This function allows you to specify the labels and corresponding colors for each data series in the plot. You can also customize the appearance of the legend, such as the location and font size.

4. Can I change the shape of the points in a plot graph in Matlab?

Yes, you can change the shape of the points in a plot graph in Matlab. The "scatter" function allows you to specify the shape of the points by using different marker symbols, such as circles, squares, or triangles. You can also change the size and color of the markers.

5. How do I add a title and labels to a plot graph with different colors in Matlab?

To add a title and labels to a plot graph with different colors in Matlab, you can use the "title", "xlabel", and "ylabel" functions. These functions allow you to specify the text and appearance of the title and labels. You can also add a colorbar to the graph to show the color scale used for the data points.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
52
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
603
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
1K
Back
Top