<https://lh3.googleusercontent.com/-5GfOebutCfE/WDBr8AaSxVI/AAAAAAAAAJY/1mw_sLtVIKg3J4Zl76o1Jy-TQmNDBHPQwCLcB/s1600/generate-histogram3d-v1.png>
 
<https://lh3.googleusercontent.com/-pOdQ2JXJYgE/WDBtFvJWOSI/AAAAAAAAAJk/MFe5OpGHuTMnrkUHktVpV0gv1I3zdHbUACLcB/s1600/generate-histogram3d-v2.png>

Hello, 

I'm working with code that creates 2D histograms (3-dimensional plots) from 
data in 2D tuples of the form (gap1, gap2). I have been using Mathematica's 
Histogram3D function 
(https://reference.wolfram.com/language/ref/Histogram3D.html) to perform 
the plotting after writing my tuple data to file. The resulting plots look 
approximately like the previous images, where the second image is the 
corresponding 2D density plot of the pair data. So far I have been able to 
replicate the density plot with matplotlib using 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')

## def

Is there an existing routine in Sage that will create the 3d-plotted data 
like the first image with Mathematica's Histogram3D plot in the above 
images? If not, please let me know if there is any interest in adding this 
functionality to Sage's Histogram code. I would like to write this 
extension if there's not already a function like it available in Sage. 

Sincerely, 

Maxie

-- 
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