-2

Here is an example of a picture I drew.

   /      /
  /      /
 /      /

I want to rotate it like this:

l     l
l     l
l     l       

What should I do?

This is my code.

plt.figure(figsize=(20,15))

route_start=[34.45, 126.05]

route_end = [34.4, 126.1]

plt.scatter(df.lon.values, df.lat.values, alpha=0.3)

plt.plot([route_start[1],route_end[1]],[route_start[0],route_end[0]],'b-')

[enter image description here][1]

[enter image description here][2]

I wanna [1] image to [2] image. [1]: https://i.stack.imgur.com/xFYsr.png [2]: https://i.stack.imgur.com/NGu3r.png

강윤희
  • 11
  • 2

2 Answers2

0

You can do this by using scipy.ndimage.

Here's the code, you hadn't provide enough information about your problem, so just example:

import scipy.ndimage as ndimage
new_img = ndimage.rotate(img, <angle>, reshape=True)

new_img is rotated to given angle. You can play with reshape=True/False.

Don't forget to mark this as answer if it helps you to solve your problem, and if any queries ask in comment.

imxitiz
  • 3,920
  • 3
  • 9
  • 33
  • Thanks. This is my code. plt.figure(figsize=(20,15)) route_start=[34.45, 126.05] route_end = [34.4, 126.1] plt.scatter(df.lon.values, df.lat.values, alpha=0.3) plt.plot([route_start[1], route_end[1]], [route_start[0], route_end[0]],'b-') – 강윤희 Jul 14 '21 at 05:49
  • @강윤희 please edit your question and add them! – imxitiz Jul 14 '21 at 05:51
  • I edited it. Please confirm. uu .. – 강윤희 Jul 14 '21 at 05:59
0

Your question is not very clear. Maybe you are trying to rotate an image. If you are actually trying to rotate a plot or an image this should help. This answer was adapted from the following posts:

Rotate image post
Plot to image IO post

enter image description here

import matplotlib.pyplot as plt
from scipy import ndimage
import io

fig, ax = plt.subplots(figsize=(12,8))
ax.plot([0, 0.5], [0, 1])
ax.plot([1, 1.5], [0, 1])

buff = io.BytesIO()
plt.savefig(buff, format='png')
buff.seek(0)

img = plt.imread(buff)
rotated_img = ndimage.rotate(img, 30)

show_img = plt.imshow(rotated_img)
plt.axis('off')
Coup
  • 695
  • 4
  • 6