Search code examples
language-agnosticopen-sourcevisualizationcharts

What type of chart would you choose for this problem, and what charting library can provide it?


Suppose I have N segments, each one having a start and a end value, for example:

[1,40],[40,80],[80,100],[90,110]

I'd like to create a chart where I can display all of them, in such a way that I can see that the fourth segment overlaps the values of the third one.

I'm new to charting, can you suggest which chart type I could use for this kind of "problem"? Also, if you'd be able to suggest a library which supports that type of chart, that would be great. I can use any of : Java,Ruby,Python,Perl,.NET. The app that will generate this kind of chart will be ran on a Windows computer.

Thanks!


Solution

  • You can implement something like Xinxua's answer in python using matplotlib like this:

    import matplotlib.pyplot as plt
    from pylab import zeros
    
    data = [[1,40],[40,80],[80,100],[90,110]]
    N = len(data)
    plt.figure()
    start_points = [x[0] for x in data]
    lengths = [x[1]-x[0] for x in data]
    z = zeros(N)
    plt.errorbar(x=start_points, y=range(N), xerr=[z,lengths], fmt='o', xuplims=True)
    plt.grid(True)
    plt.axis(ymax=N-.5)
    

    Which would give you image of results using matplotlib