# Dashed line in a one variable parametric_plot3d

Say you have a 3d line parametric plot (or parametric_plot3d with one variable). How can you stile the resulting plotted line in a dashed style?

Checked out the documentation and I noticed parametric_plot3d has an option for border_style. However it looks like this has no affect when the area is zero.

There appears to be linestyle available to 2d plots but this has no effect in 3d plots whether specified directly or in border_style.

I also tried giving the colour a colourmap via colormaps.autumn but I get an error:

TypeError: unable to simplify to float approximation

### Example

Below is the specific example I'm trying to dash. It is the second parametric_plot3d with the comments:

var(['x', 'y', 'z', 'u', 'v', 'r', 'theta'])

angle = 30 * pi / 180

show(
parametric_plot3d(
(
r*cos(theta),
r*sin(theta),
r/tan(30 * pi / 180)
),
(theta, 0, 2*pi),
opacity = 0.5
)
+ point3d((radius(z = 0.5), 0, 0.5), color = 'red')
+ parametric_plot3d(
(
0.5
),
(theta, 0, 2*pi),
# color = 'red', # Produces a solid red line
# color = (theta, colormaps.autumn) # Throws an error
# linestyle = '--', # Does not work
# boundary_style = {  # Does not work
#   'thickness': 5,
#   'linestyle': '--',
#   'color': 'red'
# }
)
)

edit retag close merge delete

Sort by ยป oldest newest most voted

One can use some workarounds

var('x y z u v r theta')
angle = pi/6
p=parametric_plot3d((r*cos(theta),
r*sin(theta),
r/tan(angle)),
(theta, 0, 2*pi),opacity = 0.3,color='lightgray')
p += point3d((radius(z = 0.5), 0, 0.5), color = 'red',size=11)
0.5) for theta in srange(0,2*pi,0.2)],
color='blue')
p.show(frame=False)


You can also add a configurable continuous line

p += line3d([(radius(z = 0.5)*cos(theta),
0.5) for theta in srange(0,2*pi,0.2)],

more

Thanks for your answer! The first one works pretty well. Not the best looking but the best I've seen so far, thank you! The second example shows a solid circle with one small gap in it for me though.

( 2023-06-29 00:56:49 +0200 )edit

The gap in solid circle is my fault, one can use for example srange(0,2*pi+0.2,0.2).

In matplotlib linestyle='--' works fine in 3d

import numpy as np
import matplotlib.pyplot as plt
theta = np.linspace(0, 2* np.pi, 100)
z = np.ones(100)*0.5
r = 0.5
x = r * np.sin(theta)
y = r * np.cos(theta)
ax.set_axis_off()
ax.plot(x, y, z, linestyle='--')
plt.show()

( 2023-06-29 10:17:38 +0200 )edit

The naming is maybe a bit misleading but

• parametric_plot is for 2d or 3d parametric arcs or curves
• parametric_plot3d is for 3d parametric surfaces
more

Thanks for your answer! Yes I am aware of the difference between parametric_plot and parametric_plot3d, or at least I think I am. According to the documentation when 3 functions are used in parametric_plot, it behaves the same as parametric_plot3d. I gave it a try anyway but unfortunately, linestyle = '--' has no effect with parametric_plot.

( 2023-06-29 01:01:51 +0200 )edit