#Coloring



### Cartesian Line Plot


```
from sympy.plotting import plot, plot_parametric, plot3d, plot3d_parametric_line, plot3d_parametric_surface
```


```
p = plot(sin(x))
```



If the `line_color` aesthetic is a function of arity 1 then the coloring is a function of the x value of a point.


```
p[0].line_color = lambda a : a

p.show()
```



If the arity is 2 then the coloring is a function of both coordinates.


```
p[0].line_color = lambda a, b : b

p.show()
```

### Parametric Lines


```
p = plot_parametric(x*sin(x), x*cos(x), (x,  0, 10))
```



If the arity is 1 the coloring depends on the parameter.


```
p[0].line_color = lambda a : a

p.show()
```



For arity 2 the coloring depends on coordinates.


```
p[0].line_color = lambda a, b : a

p.show()
```


```
p[0].line_color = lambda a, b : b

p.show()
```

### 3D Parametric line



Arity 1 - the first parameter. Arity 2 or 3 - the first two coordinates or all coordinates.


```
p = plot3d_parametric_line(sin(x)+0.1*sin(x)*cos(7*x),

         cos(x)+0.1*cos(x)*cos(7*x),

         0.1*sin(7*x),

         (x, 0, 2*pi))
```


```
p[0].line_color = lambda a : sin(4*a)

p.show()
```


```
p[0].line_color = lambda a, b : b

p.show()
```


```
p[0].line_color = lambda a, b, c : c

p.show()
```

### Cartesian Surface Plot


```
p = plot3d(sin(x)*y, (x, 0, 6*pi), (y, -5, 5))
```



Arity 1, 2 or 3 for first, the two first or all coordinates.


```
p[0].surface_color = lambda a : a

p.show()
```


```
p[0].surface_color = lambda a, b : b

p.show()
```


```
p[0].surface_color = lambda a, b, c : c

p.show()
```


```
p[0].surface_color = lambda a, b, c : sqrt((a-3*pi)**2+b**2)

p.show()
```

### Parametric surface plots



Arity 1 or 2 - first or both parameters.


```
p = plot3d_parametric_surface(x*cos(4*y), x*sin(4*y), y,

         (x, -1, 1), (y, -1, 1))
```


```
p[0].surface_color = lambda a : a

p.show()
```


```
p[0].surface_color = lambda a, b : a*b

p.show()
```

Arrity of 3 will color by coordinates.


```
p[0].surface_color = lambda a, b, c : sqrt(a**2+b**2+c**2)

p.show()
```

4f661a0ada771f7d1942353c75686ef3e1a87873
ipynb
Jupyter Notebook
examples/beginner/plot_colors.ipynb
Michal-Gagala/sympy
3cc756c2af73b5506102abaeefd1b654e286e2c8
MIT
examples/beginner/plot_colors.ipynb
Michal-Gagala/sympy
3cc756c2af73b5506102abaeefd1b654e286e2c8
MIT
examples/beginner/plot_colors.ipynb
Michal-Gagala/sympy
3cc756c2af73b5506102abaeefd1b654e286e2c8
MIT
Qwen/Qwen-72B
1. YES
2. YES