matplotlibplot3dmatplotlib-3d

Setting 3D-plot scale to logarithmic in Matplotlib giving an almost empty 2D plot


I'm trying to set the scale of a plot to logarithmic, using the code below. When plotting without the log scale, it gives me a correct plot.

for it, folder in enumerate(norm_folder_list):
    fig = plt.figure(figsize=(10, 8))
    ax = fig.add_subplot(111, projection='3d')
    ax.scatter(folder_data_real[it][0], folder_data_real[it][1], folder_data_real[it][2])

    
    ax.set_xlabel('Frequency')
    ax.set_ylabel('Time')
    ax.set_zlabel('Permittivity')


    ax.set_xscale('log')
    ax.set_yscale('log')
    ax.set_zscale('log')

However, the plot I am obtaining when using the log scale is as follows: Weird plot

I have never come across this, and can't seem to find anything about it online.

I tried plotting using different libraries, and the different libraries worked. However, for specific reasons, I need to use matplotlib3D for this.


Solution

  • Some values in some of the axes had invalid values for the logarithmic scale. Matplotlib does not account for these and, thus these values need to be removed before attempting to plot.

    As an alternative, libraries such as plotly are able to account for these kind of values.