0

I use the following csv files: file1 and file2

to plot the following subplot:

enter image description here

The code to generate the subplot is the following:

df = {}
df[1] = pd.read_csv('file1.csv')
df[2] = pd.read_csv('file1.csv')

fig, axes = plt.subplots(1, 2, figsize=(10, 5), sharey=True)
for bet in [[1, 0], [2, 1]]:
    betas = reg[bet[0]]
    betas = betas.ix[int_col]
    betas.dropna(inplace=1)
    betas.index = range(25)
    ax = betas.plot(ax=axes[bet[1]], grid=False,  style=['b-', 'b--', 'b--'],
                    legend=None)
    ax.lines[0].set_linewidth(1.5)
    ax.lines[1].set_linewidth(0.6)
    ax.lines[2].set_linewidth(0.6)
    ax.axhline(y=0, color='k', linestyle='-', alpha=0.25, linewidth=0.5)
    ax.axvline(x=13, color='k', linestyle='-', alpha=0.25, linewidth=0.5)
    ax.set_xticks([0, 6, 13, 19, 24])

These plots show coefficients from a regression (solid blue lines) and the confidence intervals (dashed-lines). As you can see, both plots in the subplot have outliers... the first point at x=0. The outliers are important but it "deform" my graphs where the other points appear to be in a straight line but in fact there is important variations at x > 0.

What would be the proper data visualization to show both the outlier and have a better "zoom" on the other points at x > 0. Is a broken y-axis the best way? How can I do so in a subplot? Other suggestions?

Anton Protopopov
  • 30,354
  • 12
  • 88
  • 93
Plug4
  • 3,838
  • 9
  • 51
  • 79
  • Since this is a programming site, it's not really the right place to ask what the "proper" data visualization is, only how to program the right visualization once you decide what it is. One option is to simply have two plots, one showing all the data and one with the outliers trimmed, and then explanation in your text. How to handle outliers depends on what you're doing and why the outliers are outliers. – BrenBarn Jan 18 '16 at 07:37
  • But I do have a programming question, if I want a broken y-axis in a subplot, how can I do so? – Plug4 Jan 18 '16 at 07:48
  • That part of your question is probably a duplicate of [this one](http://stackoverflow.com/questions/32185411/break-in-x-axis-of-matplotlib). – BrenBarn Jan 18 '16 at 08:16
  • oh I see. OK then I will have to see how I can produce many plots wtih broken y-axis in a subplot – Plug4 Jan 18 '16 at 08:57

0 Answers0