-
Hi. I have imported an STL file as a Mesh, and I want to combine this Mesh with a 2D plot. I have created my plot by But when I add this to my overall plot using The plot has a different axes from the mesh. Many thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
Beta Was this translation helpful? Give feedback.
-
x- axis is by default already at the same scaling of the world coordinates (where the 3D mesh lives). |
Beta Was this translation helpful? Give feedback.
-
I've added a new example in the gallery: """Add a secondary y-axis for units conversion"""
from vedo import np, settings, dataurl, Mesh, show
from vedo.pyplot import plot, Figure
settings.annotatedCubeTexts = ['front','back','left','right','top','bttm']
msh = Mesh(dataurl+"cessna.vtk")
x0, x1 = [0.3, 2.0]
x = np.linspace(x0, x1, num=50)
# the main plot
fig1 = plot(
x,
1000*np.cos(x+1),
xlim=[x0, x1],
ylim=[-1000, 250],
aspect=16/9,
padding=0,
title="Wing pull vs position",
xtitle="Distance from central axis [m]",
ytitle="N [Kg*m/s^2 ]",
)
# this empty Figure just creates a new y-axis
fig2 = Figure(
fig1.xlim, # same as fig1
np.array(fig1.ylim) * 7.236, # conversion factor
aspect=fig1.aspect, # same as fig1
padding=fig1.padding, # same as fig1
xtitle='', # don't draw x-axis!
ytitle='Poundal [lb*ft/s^2 ]',
axes=dict( # extra options for y-axis
yShiftAlongX=1, # shift 100% to the right
yLabelOffset=-2,
yLabelJustify="center-left",
yTitlePosition=0.5,
yTitleJustify="top-center",
yTitleOffset=-0.15,
axesLineWidth=3,
c='red3',
),
)
fig1.rotateX(90).rotateZ(90).shift(-0.5, 0, 1)
fig2.rotateX(90).rotateZ(90).shift(-0.5, 0, 1)
cam = dict(
pos=(4.119, -1.698, 1.423),
focalPoint=(-0.2014, 0.6180, 0.2593),
viewup=(-0.1925, 0.1297, 0.9727),
)
show(msh, fig1, fig2, __doc__, axes=5, camera=cam, bg2='lb').close() |
Beta Was this translation helpful? Give feedback.
x- axis is by default already at the same scaling of the world coordinates (where the 3D mesh lives).
In that case you don't need aspect="equal", just set the aspect ratio that you like (default is 4/3).
Not sure if that answers your question though..