3

I'm making a simple plot of an exponentially decaying cos curve in python. The code is below, there's no problem with the code actually running, I was just wondering if there's a way to change the way python displays the graph so rather than being enclosed by the axes like this it has the axes like this. It's not an urgent problem, it's just to make the plot match more closely with other parts of my report.

import matplotlib as mpl
import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure()
t = np.linspace(0, 4, 10000)
r=1
x = t
y = r * np.exp(-t)*np.cos(10*t)

plt.plot(x,y,'-')
plt.plot(x,np.zeros(10000),'k-')
plt.show()

1 Answer 1

2

Take a look at the Axis line style demo from the matplotlib gallery.

Specifically, the lines:

ax = SubplotZero(fig, 111)

...

for direction in ["left", "right", "bottom", "top"]: 
    ax.axis[direction].set_visible(False)
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I couldn't find it on the matplotlib site for some reason, guess I didn't look hard enough!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.