<div dir="ltr"><span class="gI"></span>Hi all,<br><br>I posted this question in Stackoverflow (<a href="http://stackoverflow.com/questions/7355497/curious-bad-behavior-creating-all-sky-projections-with-matplotlib">http://stackoverflow.com/questions/7355497/curious-bad-behavior-creating-all-sky-projections-with-matplotlib</a>) but I haven&#39;t get any answer so far, so I hope some of you can help me :-)<br>
<br>In short, I am plotting a density all-sky plot using the molloweide projection.  I create objects with coordinates ranging from 0 to 360 deg in RA and from -45 to 90 deg in DEC, but the output I get is the following:<br>
<br>image1.png -&gt; <a href="http://i56.tinypic.com/24mu96s.png">http://i56.tinypic.com/24mu96s.png</a><br><br>A plot which is OK in RA (0-360) but in DEC ranges only between -35 to 90, so I am missing 10 degrees in the south. <br>
<br>But I would expect this image:<br><br>image2.png -&gt; <a href="http://oi53.tinypic.com/2yl1nch.jpg">http://oi53.tinypic.com/2yl1nch.jpg</a><br>A plot ranging between 0 to360 and -45 to 90 as it was defined<br><br>I attach the self-contained code to produce these images, I hope someone can tell me if I am doing something wrong that I can&#39;t notice now  or misunderstanding something in the code or if there is a curious bug in 
matplotlib??<br><br><br>############the self-contained example################<br><pre class="default prettyprint"><code><span class="kwd">import</span><span class="pln"> numpy </span><span class="kwd">as</span><span class="pln"> np<br>
</span><span class="kwd">import</span><span class="pln"> matplotlib</span><span class="pun">.</span><span class="pln">pyplot </span><span class="kwd">as</span><span class="pln"> plt<br></span><span class="kwd">import</span><span class="pln"> matplotlib</span><span class="pun">.</span><span class="pln">backends</span><span class="pun">.</span><span class="pln">backend_agg<br>
</span><span class="kwd">from</span><span class="pln"> math </span><span class="kwd">import</span><span class="pln"> pi<br><br></span><span class="com">#array between 0 and 360 deg</span><span class="pln"><br>RA </span><span class="pun">=</span><span class="pln"> np</span><span class="pun">.</span><span class="pln">random</span><span class="pun">.</span><span class="pln">random</span><span class="pun">(</span><span class="lit">10000</span><span class="pun">)*</span><span class="lit">360</span><span class="pln"><br>
</span><span class="com">#array between -45 and 90 degrees. By construction!</span><span class="pln"><br>DEC</span><span class="pun">=</span><span class="pln"> np</span><span class="pun">.</span><span class="pln">random</span><span class="pun">.</span><span class="pln">random</span><span class="pun">(</span><span class="lit">10000</span><span class="pun">)*</span><span class="lit">135</span><span class="pun">-</span><span class="lit">45</span><span class="pln"><br>
<br>fig </span><span class="pun">=</span><span class="pln"> plt</span><span class="pun">.</span><span class="typ">Figure</span><span class="pun">((</span><span class="lit">10</span><span class="pun">,</span><span class="pln"> 5</span><span class="lit"></span><span class="pun">))</span><span class="pln"><br>
ax </span><span class="pun">=</span><span class="pln"> fig</span><span class="pun">.</span><span class="pln">add_subplot</span><span class="pun">(</span><span class="lit">111</span><span class="pun">,</span><span class="pln">projection</span><span class="pun">=</span><span class="str">&#39;mollweide&#39;</span><span class="pun">)</span><span class="pln"><br>
ax</span><span class="pun">.</span><span class="pln">grid</span><span class="pun">(</span><span class="kwd">True</span><span class="pun">)</span><span class="pln"><br>ax</span><span class="pun">.</span><span class="pln">set_xlabel</span><span class="pun">(</span><span class="str">&#39;RA&#39;</span><span class="pun">)</span><span class="pln"><br>
ax</span><span class="pun">.</span><span class="pln">set_ylabel</span><span class="pun">(</span><span class="str">&#39;DEC&#39;</span><span class="pun">)</span><span class="pln"><br><br>ax</span><span class="pun">.</span><span class="pln">set_xticklabels</span><span class="pun">(</span><span class="pln">np</span><span class="pun">.</span><span class="pln">arange</span><span class="pun">(</span><span class="lit">30</span><span class="pun">,</span><span class="lit">331</span><span class="pun">,</span><span class="lit">30</span><span class="pun">))</span><span class="pln"><br>
hist</span><span class="pun">,</span><span class="pln">xedges</span><span class="pun">,</span><span class="pln">yedges </span><span class="pun">=</span><span class="pln"> np</span><span class="pun">.</span><span class="pln">histogram2d</span><span class="pun">(</span><span class="pln">DEC</span><span class="pun">,</span><span class="pln">RA</span><span class="pun">,</span><span class="pln">bins</span><span class="pun">=[</span><span class="lit">90</span><span class="pun">,</span><span class="lit">180</span><span class="pun">],</span><span class="pln">range</span><span class="pun">=[[-</span><span class="lit">90</span><span class="pun">,</span><span class="lit">90</span><span class="pun">],[</span><span class="lit">0</span><span class="pun">,</span><span class="lit">360</span><span class="pun">]])</span><span class="pln"><br>
</span><span class="com">#TO RECOVER THE EXPECTED BEHAVIOUR (image2.png), I HAVE TO CHANGE -90 FOR -80 IN THE PREVIOUS LINE:</span><span class="pln"><br></span><span class="com">#hist,xedges,yedges = np.histogram2d(DEC,RA,bins=[90,180],range=[[-80,90],[0,360]])</span><span class="pln"><br>
</span><span class="com">#I DO NOT WHY!</span><span class="pln"><br><br>extent </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(-</span><span class="pln">pi</span><span class="pun">,</span><span class="pln">pi</span><span class="pun">,-</span><span class="pln">pi</span><span class="pun">/</span><span class="lit">2.</span><span class="pun">,</span><span class="pln">pi</span><span class="pun">/</span><span class="lit">2.</span><span class="pun">)</span><span class="pln"><br>
image </span><span class="pun">=</span><span class="pln"> ax</span><span class="pun">.</span><span class="pln">imshow</span><span class="pun">(</span><span class="pln">hist</span><span class="pun">,</span><span class="pln">extent</span><span class="pun">=</span><span class="pln">extent</span><span class="pun">,</span><span class="pln">clip_on</span><span class="pun">=</span><span class="kwd">False</span><span class="pun">,</span><span class="pln">aspect</span><span class="pun">=</span><span class="lit">0.5</span><span class="pun">,</span><span class="pln">origin</span><span class="pun">=</span><span class="str">&#39;lower&#39;</span><span class="pun">)</span><span class="pln"><br>
<br>cb </span><span class="pun">=</span><span class="pln"> fig</span><span class="pun">.</span><span class="pln">colorbar</span><span class="pun">(</span><span class="pln">image</span><span class="pun">,</span><span class="pln"> orientation</span><span class="pun">=</span><span class="str">&#39;horizontal&#39;</span><span class="pun">)</span><span class="pln"><br>
canvas </span><span class="pun">=</span><span class="pln"> matplotlib</span><span class="pun">.</span><span class="pln">backends</span><span class="pun">.</span><span class="pln">backend_agg</span><span class="pun">.</span><span class="typ">FigureCanvasAgg</span><span class="pun">(</span><span class="pln">fig</span><span class="pun">)</span><span class="pln"><br>
<br>fig</span><span class="pun">.</span><span class="pln">canvas</span><span class="pun">.</span><span class="pln">print_figure</span><span class="pun">(</span><span class="str">&quot;image1.png&quot;</span><span class="pun">)</span><span class="pln"><br>
</span></code></pre>######################################################<br><br>Thanks,<br><br><br><br>-- <br>Eduardo Baņados<br><br>
</div>