ANEW -log_demo NEEDS -gaussj NEEDS -gnuplot DOC (* import numpy as np import matplotlib.pyplot as plt plt.subplots_adjust(hspace=0.4) t = np.arange(0.01, 20.0, 0.01) # log y axis plt.subplot(221) plt.semilogy(t, np.exp(-t/5.0)) plt.title('semilogy') plt.grid(True) # log x axis plt.subplot(222) plt.semilogx(t, np.sin(2*np.pi*t)) plt.title('semilogx') plt.grid(True) # log x and y axis plt.subplot(223) plt.loglog(t, 20*np.exp(-t/10.0), basex=2) plt.grid(True) plt.title('loglog base 4 on x') # with errorbars: clip non-positive values ax = plt.subplot(224) ax.set_xscale("log", nonposx='clip') ax.set_yscale("log", nonposy='clip') x = 10.0**np.linspace(0.0, 2.0, 20) y = x**2.0 plt.errorbar(x, y, xerr=0.1*x, yerr=5.0+0.75*y) ax.set_ylim(ymin=0.1) ax.set_title('Errorbars go negative') plt.show() *) ENDDOC : func1 ( F: t -- r ) -5e F/ FEXP ; : func2 ( F: t -- r ) PI*2 F* FSIN ; : func3 ( F: t -- r ) -10e F/ FEXP 20e F* ; : func4 ( F: t -- r ) PI*2 F* FCOS ; : log_demo ( -- ) #2000 DOUBLE LARRAY t{ 0 FIGURE CLF TRUE GRID t{ 0e 20e #2000 LINSPACE S" Types of logarithmic plots" TITLE 2 2 SUBPLOT [SEMILOGY 0e 20e S" blue" ['] func1 #2000 FPLOT SEMILOGY] [SEMILOGX 0e 20e S" blue" ['] func2 #2000 FPLOT SEMILOGX] [LOGLOG 0e 20e S" blue" ['] func3 #2000 FPLOT LOGLOG] [SEMILOGX 0e 20e S" blue" ['] func4 #2000 FPLOT SEMILOGX] SPEND t{ }free ;