Giter Site home page Giter Site logo

Comments (4)

cing avatar cing commented on June 12, 2024 1

Wow, I was not aware this functionality existed. Are there any plots where this will not work? An interesting special case might be https://github.com/msmexplorer/msmexplorer/issues/105 , where the time colorbar is smoke and mirrors anyway?

Anyway, adding a frames_to_ns argument and two lines to each function doesn't seem too painful to me.

from msmexplorer.

msultan avatar msultan commented on June 12, 2024

from msmexplorer.

jeiros avatar jeiros commented on June 12, 2024

The way I've done this before is using FuncFormatter

You can just use the normal plotting functions and change them using a function that you define:

from matplotlib.ticker import FuncFormatter
import numpy as np
from msmexplorer import plot_trace

ts = .1
def to_ns(x, pos):
    return '{}'.format(x * ts)

a = np.random.random_sample(size=(500, 1))

ax, _ = plot_trace(a)
plt.show()

download1

ax, _ = plot_trace(a)
formatter = FuncFormatter(to_ns)
ax.xaxis.set_major_formatter(formatter)
plt.show()

download2

from msmexplorer.

jeiros avatar jeiros commented on June 12, 2024

A minor improvement that I found out is that you can specify a third arg for the to_ns function so the timestep does not have to be known a priori (just be passed as a variable using functools.partial):

from matplotlib.ticker import FuncFormatter
import numpy as np
from msmexplorer import plot_trace
from matplotlib import pyplot as plt
from functools import partial


def to_ns(x, pos, ts):
    return '{}'.format(x * ts)

a = np.random.random_sample(size=(500, 1))

ax, _ = plot_trace(a)
formatter = FuncFormatter(partial(to_ns, ts=0.1))
ax.xaxis.set_major_formatter(formatter)
plt.show()

from msmexplorer.

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.