python - Matplotlib log scale with limit turns off the bottom/up plot spine -


i trying produce log (base 2 ) plot keep getting plot no top/bottom border.

import matplotlib.pyplot plt matplotlib.ticker import scalarformatter  def tok (array):     return map (lambda x: x/1000.0, array)   yy = [2603.76, 41077.89,48961.74, 43471.14] xx = [1,16,32,64]  ax = plt.subplot(221, axisbg = 'white') ax.set_xlim(0, 128)   ax.set_xscale('log', basex=2)    ax.plot( xx, tok(yy), label="0%", linestyle='--',  marker='o', clip_on = false)  plt.savefig('./tx2.pdf', bbox_inches='tight') 

unboder plit

how can correctly ?

that's because have 0 limit while using log scale. (0 @ negative infinity on log scale)

setting axis limits include 0 should arguably raise error, @ moment, silently causes things break.

if want have 0 on plot, use symlog instead of log. however, in case, makes lot more sense have minimum 2^-1 (i.e. 0.5) instead.

for example, either this:

import matplotlib.pyplot plt import numpy np  yy = np.array([2603.76, 41077.89,48961.74, 43471.14]) xx = [1,16,32,64]  fig, ax = plt.subplots() ax.set_xlim(0.5, 128)  ax.set_xscale('log', basex=2)  ax.plot(xx, yy / 1000, linestyle='--',  marker='o', clip_on=false) plt.show() 

enter image description here

or use "symlog" instead of log scale:

import matplotlib.pyplot plt import numpy np  yy = np.array([2603.76, 41077.89,48961.74, 43471.14]) xx = [1,16,32,64]  fig, ax = plt.subplots() ax.set_xlim(0, 128)  ax.set_xscale('symlog', basex=2)  ax.plot(xx, yy / 1000, linestyle='--',  marker='o', clip_on=false) plt.show() 

enter image description here


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -