8000 A demo for errorbar function in mplot3d · GitHub
[go: up one dir, main page]

Skip to content

Instantly share code, notes, and snippets.

@vlas-sokolov
Created February 6, 2017 14:44
Show Gist options
  • Save vlas-sokolov/9987d136a0c68abdf5c3a0d9c196822c to your computer and use it in GitHub Desktop.
Save vlas-sokolov/9987d136a0c68abdf5c3a0d9c196822c to your computer and use it in GitHub Desktop.
A demo for errorbar function in mplot3d
"""
Errorbars in matplotlib, in 3D. Ongoing work at:
https://github.com/vlas-sokolov/matplotlib/tree/errorbars-mplot3d
Taken (almost) directly from here:
http://matplotlib.org/examples/pylab_examples/errorbar_limits.html,
for direct comparison between the two functions.
"""
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
fig = plt.figure('z-axis errors')
ax = fig.add_subplot(111, projection='3d')
x = np.arange(10.0)
y = np.arange(10.0)
z = np.sin(np.arange(10.0)/20.0*np.pi)
err = 0.2
ax.errorbar(x, y, z, zerr=err)
z = np.sin(np.arange(10.0)/20.0*np.pi) + 1
ax.errorbar(x, y, z, zerr=err, zuplims=True)
z = np.sin(np.arange(10.0)/20.0*np.pi) + 2
upperlimits = np.array([1, 0]*5)
lowerlimits = np.array([0, 1]*5)
ax.errorbar(x, y, z, zerr=err, zuplims=upperlimits, zlolims=lowerlimits)
ax.set_xlim(-1, 10)
fig = plt.figure('x-axis errors')
ax = fig.add_subplot(111, projection='3d')
x = np.arange(10.0)/10.0
y = (x + 0.1)**2
z = (x + 0.1)**2
ax.errorbar(x, y, z, xerr=err, xlolims=True)
y = (x + 0.1)**3
z = (x + 0.1)**3
ax.errorbar(x + 0.6, y, z, xerr=err, xuplims=upperlimits, xlolims=lowerlimits)
y = (x + 0.1)**4
z = (x + 0.1)**4
ax.errorbar(x + 1.2, y, z, xerr=err, xuplims=True)
ax.set_xlim(-0.2, 2.4)
ax.set_ylim(-0.1, 1.3)
ax.set_zlim(-0.1, 1.3)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
0