0

How would I plot this in the most efficient way?

ALLOC_MAX,FIRST_FIT,NEXT_FIT,BEST_FIT,WORST_FIT
10,2919643,2363084,3059065,1813777
20,717496,590656,792715,449054
30,283118,244520,280983,207911
40,173158,139927,178767,109183
50,96479,87675,111013,77294
70,55893,46203,54920,43436
100,27791,25881,27216,21652
200,8720,8629,8932,7738
300,4316,4080,4181,4066
400,2699,2646,2776,2590
500,1704,1643,1691,1656
700,848,825,848,825

My figure looks like this where each chart overlaps with eachother.

enter image description here

My idea would be to skip some values on the y axis. E.g. have a jump from two big > 150000 so I get more details on the smaller values. How could I implement this in matplotlib?

1 Answers1

0

What about using the broken axis feature provided by matplotlib to highlight what happens at smaller values?

import matplotlib.pyplot as plt
import numpy as np

# Replace here with your data
x = np.linspace(0.0, 1.0, 10_000)
y_1 = 1 / x
y_2 = y_1 * 2

# The actual plot with broken axis
fig, (ax1, ax2) = plt.subplots(2, 1, sharex=True)
fig.subplots_adjust(hspace=0.05)

ax1.plot(x, y_1)
ax1.plot(x, y_2)
ax2.plot(x, y_1)
ax2.plot(x, y_2)

ax1.set_ylim(9_000, 10_000)
ax2.set_ylim(0, 200)

ax1.spines.bottom.set_visible(False)
ax2.spines.top.set_visible(False)
ax1.xaxis.tick_top()
ax1.tick_params(labeltop=False)
ax2.xaxis.tick_bottom()

d = .5
kwargs = dict(marker=[(-1, -d), (1, d)], markersize=12,
              linestyle="none", color='k', mec='k', mew=1, clip_on=False)
ax1.plot([0, 1], [0, 0], transform=ax1.transAxes, **kwargs)
ax2.plot([0, 1], [1, 1], transform=ax2.transAxes, **kwargs)

plt.show()

enter image description here

blunova
  • 2,122
  • 3
  • 9
  • 21