How do you present the following 3D data in Matplotlib or Mayavi?

I have a large dataset that I am trying to present in 3D, hoping to discover a pattern. I spent quite a lot of time reading, researching and coding, but then I realized that the main problem is not programming, but actually choosing a way to visualize the data .

Matplotlib mplot3d offers many options (wireframe, outline, filled outline, etc.), as well as MayaVi. But there are so many options (and each with its own learning curve) that Iโ€™m almost lost and donโ€™t know where to start! So my question is, which charting method would you use if you had to deal with this data?

My data is based on date. For each point in time, I draw a value (list "Actual").

But for each point in time I also have an upper limit, a lower limit and a mid-range point. These limits and midpoints are based on seeds in different planes.

I want to define a point or define a pattern when, or before, serious changes have occurred in my "Actual" reading. This is when there are upper limits on all planes? Or approach each other? This is when the actual value relates to the upper / middle / lower limit? Is this when the Uppers in one plan touch the Lowers of another plane?

In the code I embed, I reduced the data set to a few elements. I just use simple scatter and line graphs, but due to the size of the dataset (and possibly the limitations of mplot3d?) I cannot use it to identify the trends I'm looking for.

dates = [20110101,20110104,20110105,20110106,20110107,20110108,20110111,20110112] zAxis0= [ 0, 0, 0, 0, 0, 0, 0, 0] Actual= [ 1132, 1184, 1177, 950, 1066, 1098, 1116, 1211] zAxis1= [ 1, 1, 1, 1, 1, 1, 1, 1] Tops1 = [ 1156, 1250, 1156, 1187, 1187, 1187, 1156, 1156] Mids1 = [ 1125, 1187, 1125, 1156, 1156, 1156, 1140, 1140] Lows1 = [ 1093, 1125, 1093, 1125, 1125, 1125, 1125, 1125] zAxis2= [ 2, 2, 2, 2, 2, 2, 2, 2] Tops2 = [ 1125, 1125, 1125, 1125, 1125, 1250, 1062, 1250] Mids2 = [ 1062, 1062, 1062, 1062, 1062, 1125, 1000, 1125] Lows2 = [ 1000, 1000, 1000, 1000, 1000, 1000, 937, 1000] zAxis3= [ 3, 3, 3, 3, 3, 3, 3, 3] Tops3 = [ 1250, 1250, 1250, 1250, 1250, 1250, 1250, 1250] Mids3 = [ 1187, 1187, 1187, 1187, 1187, 1187, 1187, 1187] Lows3 = [ 1125, 1125, 1000, 1125, 1125, 1093, 1093, 1000] import matplotlib.pyplot from mpl_toolkits.mplot3d import Axes3D fig = matplotlib.pyplot.figure() ax = fig.add_subplot(111, projection = '3d') #actual values ax.scatter(dates, zAxis0, Actual, color = 'c', marker = 'o') #Upper limits, Lower limts, and Mid-range for the FIRST plane ax.plot(dates, zAxis1, Tops1, color = 'r') ax.plot(dates, zAxis1, Mids1, color = 'y') ax.plot(dates, zAxis1, Lows1, color = 'b') #Upper limits, Lower limts, and Mid-range for the SECOND plane ax.plot(dates, zAxis2, Tops2, color = 'r') ax.plot(dates, zAxis2, Mids2, color = 'y') ax.plot(dates, zAxis2, Lows2, color = 'b') #Upper limits, Lower limts, and Mid-range for the THIRD plane ax.plot(dates, zAxis3, Tops3, color = 'r') ax.plot(dates, zAxis3, Mids3, color = 'y') ax.plot(dates, zAxis3, Lows3, color = 'b') #These two lines are just dummy data that plots transparent circles that #occpuy the "wall" behind my actual plots, so that the last plane appears #floating in 3D rather than being pasted to the plot background zAxis4= [ 4, 4, 4, 4, 4, 4, 4, 4] ax.scatter(dates, zAxis4, Actual, color = 'w', marker = 'o', alpha=0) matplotlib.pyplot.show() 

I get this plot, but it just doesn't help me see any relationship.

enter image description here I'm not a mathematician or scientist, so I really need help choosing FORMAT to visualize my data. Is there an efficient way to show this in mplot3d? Or would you use MayaVis? In any case, which library and classes are you using?

Thanks in advance.

+7
source share
2 answers

To comment on part of your visualization (rather than programming), I set out some examples of facet graphs to suggest alternatives that you can use to examine your data.

 library("lubridate") library("ggplot2") library("reshape2") dates <- c("2011-01-01","2011-01-04","2011-01-05", "2011-01-06","2011-01-07","2011-01-08", "2011-01-11","2011-01-12") dates <- ymd(dates) Actual<- c( 1132, 1184, 1177, 950, 1066, 1098, 1116, 1211, 1132, 1184, 1177, 950, 1066, 1098, 1116, 1211, 1132, 1184, 1177, 950, 1066, 1098, 1116, 1211) z <- c( 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3) Tops <- c( 1156, 1250, 1156, 1187, 1187, 1187, 1156, 1156, 1125, 1125, 1125, 1125, 1125, 1250, 1062, 1250, 1250, 1250, 1250, 1250, 1250, 1250, 1250, 1250) Mids <- c( 1125, 1187, 1125, 1156, 1156, 1156, 1140, 1140, 1062, 1062, 1062, 1062, 1062, 1125, 1000, 1125, 1187, 1187, 1187, 1187, 1187, 1187, 1187, 1187) Lows <- c( 1093, 1125, 1093, 1125, 1125, 1125, 1125, 1125, 1000, 1000, 1000, 1000, 1000, 1000, 937, 1000, 1125, 1125, 1000, 1125, 1125, 1093, 1093, 1000) df <- data.frame( cbind(z, dates, Actual, Tops, Mids, Lows)) dfm <- melt(df, id.vars=c("z", "dates", "Actual")) 

In the first example, a thin blue line is the actual value superimposed on all three levels in each of the z axes.

 p <- ggplot(data = dfm, aes(x = dates, y = value, group = variable, colour = variable) ) + geom_line(size = 3) + facet_grid(variable ~ z) + geom_point(aes(x = dates, y = Actual), colour = "steelblue", size = 3) + geom_line(aes(x = dates, y = Actual), colour = "steelblue", size = 1) + theme_bw() p 

line charts

In the second set, each panel has a scatter plot of the actual value for three levels (upper, middle, low) in each of the z axes.

 p <- ggplot(data = dfm, aes(x = Actual, y = value, group = variable, colour = variable) ) + geom_point(size = 3) + geom_smooth() + facet_grid(variable ~ z) + theme_bw() p 

correlation

+7
source

Thanks gauden. R was actually part of my research, and I established it, but did not go too far in this tutorial. If this does not contradict the rules of StackOverFlow, I would be glad to see your R-code.

I already tried 2D representations, but in many cases the values โ€‹โ€‹for Tops1 / Tops2 / Tops3 (and similarly for Lows) would be equal, so the lines ended with overlapping and shading each other. That is why I am trying to use the 3D option. Your idea of โ€‹โ€‹three panels of 2D graphics is a great suggestion that I have not studied.

I will try, but I would think that the 3D plot will give me a clearer picture, especially the wireframe / grid graphics, which will show the convergence of values, and I will see that the blue dot floating in three-dimensional space, the point when the lines on the wireframe begin create a peak or gutter. I just can't get it to work.

I tried to adapt matplotlib An example of a wireframe , but the plot that I get does not look like a wireframe at all.

Here is what I get from the code below enter image description here with only two data elements (Tops1 and Tops2):

 dates = [20110101,20110104,20110105,20110106,20110107,20110108,20110111,20110112] zAxis0= [ 0, 0, 0, 0, 0, 0, 0, 0] Actual= [ 1132, 1184, 1177, 950, 1066, 1098, 1116, 1211] zAxis1= [ 1, 1, 1, 1, 1, 1, 1, 1] Tops1 = [ 1156, 1250, 1156, 1187, 1187, 1187, 1156, 1156] Mids1 = [ 1125, 1187, 1125, 1156, 1156, 1156, 1140, 1140] Lows1 = [ 1093, 1125, 1093, 1125, 1125, 1125, 1125, 1125] zAxis2= [ 2, 2, 2, 2, 2, 2, 2, 2] Tops2 = [ 1125, 1125, 1125, 1125, 1125, 1250, 1062, 1250] Mids2 = [ 1062, 1062, 1062, 1062, 1062, 1125, 1000, 1125] Lows2 = [ 1000, 1000, 1000, 1000, 1000, 1000, 937, 1000] zAxis3= [ 3, 3, 3, 3, 3, 3, 3, 3] Tops3 = [ 1250, 1250, 1250, 1250, 1250, 1250, 1250, 1250] Mids3 = [ 1187, 1187, 1187, 1187, 1187, 1187, 1187, 1187] Lows3 = [ 1125, 1125, 1000, 1125, 1125, 1093, 1093, 1000] import matplotlib.pyplot from mpl_toolkits.mplot3d import Axes3D fig = matplotlib.pyplot.figure() ax = fig.add_subplot(111, projection = '3d') ####example code from: http://matplotlib.sourceforge.net/mpl_toolkits/mplot3d/tutorial.html#wireframe-plots #from mpl_toolkits.mplot3d import axes3d #import matplotlib.pyplot as plt #import numpy as np #fig = plt.figure() #ax = fig.add_subplot(111, projection='3d') #X, Y, Z = axes3d.get_test_data(0.05) #ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10) #plt.show() X, Y, Z = dates, Tops1, Tops2 ax.plot_wireframe(X, Y, Z, rstride=1, cstride=1, color = 'g') matplotlib.pyplot.show() 
+2
source

All Articles