by Anonymous » 11 Jul 2025, 15:30
Ich möchte die Zeichnung in Matplotlib in Pil wiederholen. Vielleicht ist das Problem, dass mein Datenformat "4,005.4.006" lautet. Wie erstelle ich die gleiche Grafik in Pil? < /P>
Code: Select all
from PIL import Image, ImageDraw
import numpy as np
N = 461
x = np.linspace(0, 4*np.pi, N)
y = np.sin(x)
y=y+50
im = Image.new('L', (N, N))
draw = ImageDraw.Draw(im)
for i in range(len(x)-1):
draw.line((x[i],y[i], x[i+1], y[i+1]),fill='red',width=2)
im.show()
# this is the graphic i want to get
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot(x, y)
plt.show()
Danke im Voraus
[url=viewtopic.php?t=14917]Ich möchte[/url] die Zeichnung in Matplotlib in Pil wiederholen. Vielleicht ist das Problem, dass mein Datenformat "4,005.4.006" lautet. Wie erstelle ich die gleiche Grafik in Pil? < /P>
[code]from PIL import Image, ImageDraw
import numpy as np
N = 461
x = np.linspace(0, 4*np.pi, N)
y = np.sin(x)
y=y+50
im = Image.new('L', (N, N))
draw = ImageDraw.Draw(im)
for i in range(len(x)-1):
draw.line((x[i],y[i], x[i+1], y[i+1]),fill='red',width=2)
im.show()
# this is the graphic i want to get
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot(x, y)
plt.show()
[/code]
Danke im Voraus