ARTICLE AD BOX
I'm doing some data visualisation for an experiment on near/far field diffraction.
My goal is to essentially put several 2d plots in front of one another, pretty much identical to how this example in matplotlib's documentation does it. However, when i call the ax.fill_between() function, it seems to interpret it as a function for 2d plots, accepting only x and y arguments rather than x, y and z arguments, returning TypeError: can only concatenate str (not "int") to str
Running the example's code I linked before myself returns the same error. What causes python to interpret it as a 2d plot, even when ax is an Axes3D object?
Here is my own code:
import numpy as np import matplotlib.pyplot as plt plt.rcParams.update({'font.size': 12}) bs = np.arange(0,1001,50) colors = plt.colormaps['viridis_r'](np.linspace(0, 1, len(bs))) ax = plt.figure().add_subplot(projection='3d') for k in range(len(bs)): data = np.genfromtxt(f"meting/2.2data{bs[k]}um.txt", delimiter=",", skip_header=7) px = data[:,0] mag = data[:,1] # Plot ax.fill_between(px, bs[k], mag, px, bs[k], 0, facecolors = colors[k], alpha = 0.7) ax.set( xlim = (0,1920), xlabel = 'px', ylabel = 'Slit width', zlabel = 'intensity' ) plt.show()