Giter VIP home page Giter VIP logo

Comments (5)

nkeim avatar nkeim commented on July 28, 2024

Have you tried not calling plt.figure() beforehand?

If you want to remove all ambiguity, you can get or create axes in the current figure and make sure that plot_traj uses them. Something like (not sure if it's 100% correct):

fig = plt.figure()
ax = fig.get_axes()
tp.plot_traj(..., ax=ax)
fig.savefig(...)

from trackpy.

Rory235 avatar Rory235 commented on July 28, 2024

EDIT: Spelling
So trackpy still creates the plot without the plt.figure()

I tried this

fig1=tp.plot_traj(t1, superimpose=frame[1000]) fig1.savefig(r'C:\Users\Rory\Downloads\1.png')

but get the error

`AttributeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_24356/3548345737.py in
1 fig1=tp.plot_traj(t1, superimpose=frame[1000])
----> 2 fig1.savefig(r'C:\Users\Rory\Downloads\1.png')

AttributeError: 'AxesSubplot' object has no attribute 'savefig'`

from trackpy.

nkeim avatar nkeim commented on July 28, 2024

That's right. plot_traj returns an Axes object, not a figure. So if you are being explicit about it, you should first get the figure, then tell plot_traj to use axes within it, and then save the figure.

I'll admit I'm a bit surprised that tp.plot_traj(...); plt.savefig(filename) doesn't work. I had thought that it was that simple.

from trackpy.

Rory235 avatar Rory235 commented on July 28, 2024

Ahhhh I see. I gave this a try

fig1 = plt.figure() ax = fig1.get_axes() tp.plot_traj(t1, ax=ax) fig1.savefig(r'C:\Users\Rory\Downloads\1.png')

getting

AttributeError: 'list' object has no attribute 'set_xlabel'

from trackpy.

nkeim avatar nkeim commented on July 28, 2024

You're asking the wrong person for matplotlib help, but you could do this instead.

fig = plt.figure()
ax = plt.gca()
tp.plot_traj(..., ax=ax)
fig.savefig(...)

or

ax = tp.plot_traj(...)
ax.figure.savefig(...)

from trackpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.