Hello, 

I'm plotting 2D histograms (3D plots) of 2D tuples of the form (gap1, gap2) 
with Mathematica's Histogram3D function. I'm currently writing the tuple 
data out to file with Sage / Python and then loading the data into a 
working Mathematica notebook so I can use Mathematica's Histogram3D and 
DensityHistogram functions on the data 
(https://reference.wolfram.com/language/ref/Histogram3D.html and 
https://reference.wolfram.com/language/ref/DensityHistogram.html). The 
results of my plots look approximately like the attached images, where the 
second image is the corresponding 2D density plot of the data. So far, I 
have been able to reproduce the second density plot output in Sage with the 
following code: 

import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from sage.all import *
from sage.plot.histogram import Histogram

def Histogram3D(xypoints, numbins):

     xpoints = map(lambda (x, y): x, xypoints)
     ypoints = map(lambda (x, y): y, xypoints)
     minx, maxx, miny, maxy = min(xpoints), max(xpoints), \
                              min(ypoints), max(ypoints)
     xedges = np.arange(minx, maxx, (maxx - minx) / float(numbins))
     yedges = np.arange(miny, maxy, (maxy - miny) / float(numbins))
     H, xedges, yedges = np.histogram2d(ypoints, xpoints, bins = (xedges, 
yedges))
     
     fig = plt.figure(figsize=(7, 3))
     ax = fig.add_subplot(132)
     ax.set_title('pcolormesh: exact bin edges')
     X, Y = np.meshgrid(xedges, yedges)
     ax.pcolormesh(X, Y, H)
     ax.set_aspect('equal')
     plt.savefig('./output/foo.png', bbox_inches='tight')
     #plt.show()
     
##

Is there an existing Sage function that will allow me to generate plots 
like the first image created with Mathematica's Histogram3D? If not, is 
there any interest in this functionality being added to Sage's default 
Histogram classes? I would like to write the code to generate these 3D 
histogram plots if there isn't already an existing Sage function to do so. 

Sincerely, 

Maxie


<https://lh3.googleusercontent.com/-NlUfX7vA_d4/WDBw8mV6pEI/AAAAAAAAAJs/hxI0HFxAQwYt4xT0rhwgWhriKVTh2daowCLcB/s1600/generate-histogram3d-v1.png>
 
<https://lh3.googleusercontent.com/-k2iCCEppVu0/WDBw_lJR8SI/AAAAAAAAAJw/lzoK8-EAKXoLP1bjWRJBpU0aEhgoIWkDwCLcB/s1600/generate-histogram3d-v2.png>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to