Giter Club home page Giter Club logo

Comments (10)

andrzejnovak avatar andrzejnovak commented on June 15, 2024

next to the tick scale (outside the plot). Could you add an example, I'm not 100% sure I get what oyu mean

from mplhep.

jrueb avatar jrueb commented on June 15, 2024

Right now it looks like this
Figure_1

and what I have in mind is something like this
Figure_2

Source

import matplotlib.pyplot as plt
import mplhep as hep
import numpy as np

data = np.random.rand(1000000)
ax = plt.gca()
hep.cms.cmslabel(ax)
plt.hist(data)
ax.ticklabel_format(axis="y", style="sci", scilimits=(0, 0))
plt.show()

from mplhep.

andrzejnovak avatar andrzejnovak commented on June 15, 2024

I can take a look, It would be useful if we could get this behaviour automatically, but I am not sure how to fetch the Text object with the sci label

from mplhep.

andrzejnovak avatar andrzejnovak commented on June 15, 2024

@jrueb It might take me some time to get to it, but if you feel like fixing it, this get's you the offset of the exponent text ax.get_yaxis().offsetText.get_tightbbox(ax.figure.canvas.renderer).width

from mplhep.

andrzejnovak avatar andrzejnovak commented on June 15, 2024

@jrueb 0.0.24 should fix it, let me know

from mplhep.

jrueb avatar jrueb commented on June 15, 2024

Thanks for the fix. Unfortunately it does not seem to work at all anymore if the y axis is set to logarithmic ax.set_yscale("log").

I get AttributeError: 'LogFormatterSciNotation' object has no attribute '_scientific'. This is independent from the presence of a ax.ticklabel_format call.

from mplhep.

andrzejnovak avatar andrzejnovak commented on June 15, 2024

Ugh, ok, that was unfortunate. Next version should properly check the formatter type first.

from mplhep.

andrzejnovak avatar andrzejnovak commented on June 15, 2024

@jrueb did 0.0.25 fix this?

from mplhep.

jrueb avatar jrueb commented on June 15, 2024

Yes, it seems to work fine.
However, while I personally don't use it and did not consider before, there is the possibility of ax.yaxis.tick_right() which moves the entire issue to the right side. mplhep does not check for this yet.

from mplhep.

andrzejnovak avatar andrzejnovak commented on June 15, 2024

Ok, thanks for the heads up, but unless it comes up that's a #wontfix for me. If anyone does that much surgery to their plots they might as well place the axis themselves.

from mplhep.

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.