0

I'm trying to make a simulation of a DC motor made of two orthogonal coils. How can I have the zero of the animation fixed?

I already have an equal aspect ratio (using matplotlib 3.6) but right now the animation moves it's origin to center the plot. I don't want it to move. I want the origin fixed.

What I want to do is to make Matplotlib not to move the origin. The origin in the animation must remain fixed so it could be a motor simulation.

Here's the code I'm using:

import matplotlib.animation as animation
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits import mplot3d
from matplotlib.animation import FuncAnimation
fig=plt.figure()
ax=plt.axes(projection='3d')
line, = ax.plot3D([],[],[],lw=2)

def init():
    line.set_data([],[])
    line.set_3d_properties([])
    return line
    
def frame(t):
    ax.plot(punt0x,punt0y,punt0z)
    ax.plot(punt1x,punt1y,punt1z)
    ax.set_aspect('equal')
    ax.spines['left'].set_position('zero')
    ax.spines['bottom'].set_position('zero')

ani=animation.FuncAnimation(fig,frame,frames=360,interval=10,init_func=init)

punt0x, punt0y and punt0z are the coordinates of the points on the first coil. The ones with a 1 are related to the second coil. They are calculated in the other part of the program, that works. The problem is somewhere in the code I already have shared here.

If you need it, I'll upload the video to MediaFire. Just tell me if it's needed.

The Thonnu
  • 3,578
  • 2
  • 8
  • 30

0 Answers0