Ploting
Title
Question
<span style="color: rgb(73, 80, 87); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";">how to change color of graph and how to do simulation in phase diagram?</span>
Scilab Plotting-2D-graphs 01-02 min 0-10 sec
Answers:
I have taken one example to demonstrate how to change the color of the plot:
// Plot function
clc();
x = -%pi/2:0.01:%pi/2;
y = sin(x);
plot(x,y);
xlabel('x [rad]','FontSize',3);
ylabel('y(x)','FontSize',3);
title('y(x) = sin(x)','FontSize',5);
xgrid();
// Get graphic handles
hf = gcf();
ha = gca();
// Neon colors setup
// 2- blue, 3 - green, 4 - light blue,
// 5 - red, 6 - magenta, 7 - yellow
neon1 = 2; // grid
neon2 = 3; // ticks
neon3 = 6; // text
neon4 = 4; // line plot
// Set colors
hf.background = 0; // outer area
ha.background = 0; // inner area
ha.foreground = neon1; // axes rectangle
ha.font_color = neon2; // ticks
ha.grid =[neon1,neon1]; // grid
ha.title.font_foreground = neon3; // title
ha.x_label.font_foreground = neon3; // x-label
ha.y_label.font_foreground = neon3; // y-label
ha.children.children.foreground = neon4; // line plot
ha.children.children.thickness = 3; // line thickness
clc();
x = -%pi/2:0.01:%pi/2;
y = sin(x);
plot(x,y);
xlabel('x [rad]','FontSize',3);
ylabel('y(x)','FontSize',3);
title('y(x) = sin(x)','FontSize',5);
xgrid();
// Get graphic handles
hf = gcf();
ha = gca();
// Neon colors setup
// 2- blue, 3 - green, 4 - light blue,
// 5 - red, 6 - magenta, 7 - yellow
neon1 = 2; // grid
neon2 = 3; // ticks
neon3 = 6; // text
neon4 = 4; // line plot
// Set colors
hf.background = 0; // outer area
ha.background = 0; // inner area
ha.foreground = neon1; // axes rectangle
ha.font_color = neon2; // ticks
ha.grid =[neon1,neon1]; // grid
ha.title.font_foreground = neon3; // title
ha.x_label.font_foreground = neon3; // x-label
ha.y_label.font_foreground = neon3; // y-label
ha.children.children.foreground = neon4; // line plot
ha.children.children.thickness = 3; // line thickness
There are two ways through which you can change color of graph,
1. By using plot command, i.e. plot(x,y, color="black") or any other color of your choice. Also there are color id of every color that you can find on help browser, and then you can directly write that color id in plot command, for example: color code for red is 5, so we can use plot2d(x,y,5).
note that, if we are using color id, we use specified plot2d or plot3d.
2. color of the graph can also be changed using edit option on menu bar of the graph window,
edit>axis properties>compound(1)>polyline(1)>foreground color
Simulations in phase diagram can also be done in same manner. for many such options please go through the 'edit' option on menu bar of graph window
Login to add comment