Get mean for a specific range of TGraphErrors

so now i wanted to do:

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

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


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()
ax.plot([1,2,3],[4,5,6])

Set the range of the x-axis.

ax.xaxis.set_range_user(1,100)

Force the y-axis to update its maximum value.

ax.yaxis.update()

Get the maximum value of the y-axis.

ymax = ax.yaxis.get_xmax()

Print the maximum value of the y-axis.

print(ymax)`

Output:

6.0

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.

Cheers,
Marta

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.

Cheers,
Marta