PIL -Bildgrößenanpassung

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: PIL -Bildgrößenanpassung

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

Top