What is wrong with this command, please?
ax.plot(xs = 0, y, z, zdir='ÿ́')
^
SyntaxError: positional argument follows keyword argument
then, I tried:
ax.plot(y, z, xs = 0, zdir='ÿ́')
TypeError: plot() got multiple values for argument 'xs'
I would like to plot a 2D curve y, z on the constant x coordinate. Many thanks
Edit after advice:
How to plot three sine function, each with another constant x, please?
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d import proj3d, art3d
figsize=[9,4]
fig = plt.figure(figsize=figsize)
ax = fig.add_subplot(111, projection='3d')
ax.azim = -42 # y rotation (default=270)
ax.elev = 0 # x rotation (default=0)
ax.set_xlim(-0.055497704786691616, 0.06545180052052388)
ax.set_ylim(-0.05, 0.55)
ax.set_zlim(-0.05662598667131224, 0.08914572009755688)
plane1 = 0
plane2 = 0.5
h = 0.03
N = 1000
t = np.linspace(plane1, plane2, N)
f = 20
function = h*np.sin(t*f)
x = np.zeros(len(t))
wave_shift = 0.1
# Cycle for generating three sine curve shifted in x
for i in range(3):
ax.plot(t, function, zdir = 'x')
ax.get_proj = lambda: np.dot(Axes3D.get_proj(ax), np.diag([0.2, 1, 0.13, 1]))
# Text
ax.text3D(0.14, 0.18, -0.08, r'$d$')
margins = {
"left" : -1.5 / figsize[0],
"bottom" : -9 / figsize[1],
"right" : 0.52 + 6 / figsize[0],
"top" : 1.5 + 9.3 / figsize[1]
}
fig.subplots_adjust(**margins)
plt.show()
Desired result:
three same curves, each of them has another x value
First error: "Positional" arguments are those that are determined by their position, ie, in which order within the parenthesis they are listed, such as y, z in your example. "Keyword" arguments are those that you specify which argument it is, such as xs and zdir in your example. Positional arguments must come first, and then you can add on as many keyword arguments as you are able to. That's your first error.
As for the second error, "xs" is here interpreted as a keyword argument. You seem to want to use it as a variable held constant. I think you need to browse the matplotlib plot examples to figure out exactly what you want to be doing.
In the future, a minimum reproducable example is quite helpful, ie, it would help if you could write what your variables xs, y, z are, or better yet make up some example data.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.