Get mean for a specific range of TGraphErrors

so now i wanted to do:


but the maximum value always return the same value regardless what range i set (i am sure that the xmax will be higher for (1,100) than other region.
any workaround ?

ROOT Version: 6.24
Platform: centos 7 (conda)
Compiler: Not Provided

1 Like

To ensure that the maximum value of the y-axis is updated after setting the range of the x-axis, you can use the following workaround:

gr_x.GetXaxis().SetRangeUser(1,100) gr_x.GetYaxis().Update()

This will force the y-axis to update its maximum value based on the new range of the x-axis.

Here is an example of how to use the workaround:

`import matplotlib.pyplot as plt

Create a figure and plot some data.

fig, ax = plt.subplots()

Set the range of the x-axis.


Force the y-axis to update its maximum value.


Get the maximum value of the y-axis.

ymax = ax.yaxis.get_xmax()

Print the maximum value of the y-axis.




i am confused … this is ROOT or matplotlib ?

Hi @NgJunKai,

yes, the above will not solve your ROOT question. As for your other post (Get mean, max, min y value for a specific range on x-axis for TGraphErrors), once I have a reproducer, I will try to help you.


sorry, i just realized this is a duplicated question … How can i delete this post ?

Hi @NgJunKai,

there is no need to delete this duplicated post, but I’ll be answering in the other post.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.