TGraph Line with Large Number of Entries in jsROOT

I’ve noticed an issue plotting TGraph object with a large number of points in jsROOT. When using the "L" option the line does not connect all the points, but instead picks every nth point to connect.
Using this python code in a juypter notebook:

import numpy as np 
import ROOT
num_points = 250000 
x = np.arange(num_points, dtype='float64') 
y = np.random.randn(num_points) 
g = ROOT.TGraph(num_points, x, y) 

generates the following image, where it is clear there are points that are not connected by a line. In fact the line only connects every 50th point.

Adding the following and switching back to static images, the issue vanishes:


Is this a bug or a “feature”? I’m using ROOT 6.11/02 here, with python 2.7.


Is this a bug or a “feature”?

It is a feature. By default up to 5000 points are used when drawing lines and up to 50000 points when drawing markers. This is inconsistent and I will fix it.

50,000 points will still not enough for the figures I’m producing. Is there, or will there be, some control over this?
Thanks for the quick response.

50,000 points will still not enough for the figures I’m producing.

I need redo some performance measurements - SVG graphics can be very slow when creating too much primitives. From other side, now JSROOT creates very few primitives even when drawing large number of markers or points.

Is there, or will there be, some control over this?

In JSROOT itself one could disable graphics optimization, but one cannot change it in juypter notebooks. I will try to provide reasonable solution.

1 Like


I check performance with my actual browser - it is now much better.
Therefore drawing of many points or many lines should not be a problem.
With current developer version I can draw 250000 points easily:

I also add “noopt” draw option, which guarantees, that no any points optimization will be performed,noopt

This version will be release until end of the year and then will be used for iPython Notebooks.

For the time been you could try to use TH1 class - it should work better in JSROOT.
Even with very large number of bins it should draw complete dynamic range properly.


1 Like

Thanks for the quick work.

I can live with the static images until January. This way I only need to change a single line to switch between them.

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