<div dir="ltr">FYI, here's a simple script that shows this -- with the fix noted earlier, the tick labels are right.  I suspect that this same bug is in the other transferfunction's plot methods, so I'll wait until I have a chance to look over things before submitting a patch.<div>
<br></div><div><div>import pylab</div><div>import numpy as np</div><div>from yt.mods import *</div><div>import yt.visualization.volume_rendering.api</div><div><br></div><div>use_log = False</div><div><br></div><div>fig = pylab.figure(facecolor="black")</div>
<div><br></div><div><br></div><div>vals = [-1.e7, -5.e6, 5.e6, 1.e7]</div><div>sigma = 0.1*max(abs(np.array(vals)))</div><div><br></div><div>mi = min(vals)</div><div>ma = max(vals)</div><div>    </div><div>if use_log:</div>
<div>    mi, ma = np.log10(mi), np.log10(ma)</div><div><br></div><div>tf =  yt.visualization.volume_rendering.api.ColorTransferFunction((mi, ma))</div><div><br></div><div>for v in vals:</div><div>    if (use_log):</div><div>
        tf.sample_colormap(math.log10(v), sigma**2)</div><div>    else:</div><div>        tf.sample_colormap(v, sigma**2) #, alpha=0.2)</div><div><br></div><div><br></div><div>tf.vert_cbar()</div><div><br></div><div>pylab.savefig("test_cbar.png", facecolor=fig.get_facecolor())</div>
</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 23, 2014 at 11:06 AM, Michael Zingale <span dir="ltr"><<a href="mailto:michael.zingale@stonybrook.edu" target="_blank">michael.zingale@stonybrook.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Sam, I looked at this in more detail.  The transfer function is setting things up correctly.  As best as I can tell, the issue is in the vert_cbar routine.  In particular, since the transfer function uses linspace, which by default has endpoint=True, when we convert from indices into x values, we should divide by self.alpha.x.size-1 instead of self.alpha.x.size.  i.e., if I change the one line:<div>

<br></div><div><div>            val = x * (self.alpha.x[-1] - self.alpha.x[0]) / (self.alpha.x.size) + self.alpha.x[0]</div></div><div><br></div><div>to</div><div><div><br></div><div>            val = x * (self.alpha.x[-1] - self.alpha.x[0]) / (self.alpha.x.size-1) + self.alpha.x[0]</div>

</div><div><br></div><div>then I get the expected behavior.</div><div><br></div><div>I am a little confused as well why we do add the "+1" in np.floor(self.alpha.x[-1]) + 1, 1) when defining xticks as well -- I imagine that's a good thing if your are working with logs, but for my purpose, where x ranges from -1.e7 to 1.e7, this doesn't seem needed, but I can live with that.</div>

<div><br></div><div>Thoughts?</div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 22, 2014 at 8:32 AM, Michael Zingale <span dir="ltr"><<a href="mailto:michael.zingale@stonybrook.edu" target="_blank">michael.zingale@stonybrook.edu</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I haven't explored this in any detail yet (still dealing with the end of the semester here)</div><div>

<div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 21, 2014 at 8:38 PM, Sam Skillman <span dir="ltr"><<a href="mailto:samskillman@gmail.com" target="_blank">samskillman@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Michael,<div><br></div><div>That looks like a bug to me. I'll take a look at it in more detail tomorrow.  If you have a fix that works, let us know...</div>


<span><font color="#888888"><div><br></div><div>Sam</div></font></span></div><div><div><div class="gmail_extra">

<br><br><div class="gmail_quote">On Wed, May 21, 2014 at 8:17 AM, Michael Zingale <span dir="ltr"><<a href="mailto:michael.zingale@stonybrook.edu" target="_blank">michael.zingale@stonybrook.edu</a>></span> wrote:<br>




<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I looked at this some more.  It is this line in vert_cbar that adds the odd-valued colorbar label:<div>



<br>
</div><div>xticks = np.append(visible[-1], xticks)   <br></div><div><br></div><div>in particular, that adds the "255" value into the xticks array.  Interestingly, xticks has a 256 value with the correct x_format() behavior (mapping to 1.e7, the upper limit of my transfer function), but that is ignored, since it is outside of the bounds of the color bar.</div>





<div><br></div><div>So the question then is why when I setup a transfer function via:</div><div><br></div><div><div>    tf =  yt.visualization.volume_rendering.api.ColorTransferFunction((mi, ma))</div></div><div><br></div>





<div>with mi = -1.e7 and ma = 1.e7, does it map -1.e7 into index 0 in the palette and 1.e7 into 256 in the palette, instead of 255?</div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">

On Sun, May 11, 2014 at 6:03 PM, Michael Zingale <span dir="ltr"><<a href="mailto:michael.zingale@stonybrook.edu" target="_blank">michael.zingale@stonybrook.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I poked around that code earlier but didn't see anything odd.  I'll look some more at it tomorrow.</div>





<div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, May 10, 2014 at 11:31 AM, Chris Malone <span dir="ltr"><<a href="mailto:chris.m.malone@gmail.com" target="_blank">chris.m.malone@gmail.com</a>></span> wrote:<br>






<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Mike,<div><br></div><div>The number that is getting set (~9.92e6) is just one bin off from the maximum value (you have a range of 2e7 and the default is 256 bins).  The code that displays the colorbar, as best I can tell, occurs when you call save_annotated.  This method eventually calls ColorTransferFunction.vert_cbar where the ticks and limits are applied to the colorbar axes object.</div>







<div><br></div><div>Looking over the logic in that code, it is not immediately obvious to me why the index is off.  I suspect is has something to do with how the `visible` variable is defined, but I'd need to play with a dataset and some print statements...</div>







<div><br></div><div>Chris </div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>On Wed, May 7, 2014 at 8:17 PM, Michael Zingale <span dir="ltr"><<a href="mailto:michael.zingale@stonybrook.edu" target="_blank">michael.zingale@stonybrook.edu</a>></span> wrote:<br>







</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">I'm trying to show the transfer function on a volume render.  Plotting a velocity component, I set the transfer function with 4 Gaussians all with the same width.  The range of the transfer function is -1.e7 to 1.e7, but for some reason, when output, the upper label in the colorbar is not 1.e7 but a bit lower (9.92e6).  I am not sure where the code is that draws this, and I am confused why it is not setting the tick at 1.e7. It gets the bottom tick right.<div>








Here's an image:<br><div><br><div><a href="http://bender.astro.sunysb.edu/random/test_0000.png" target="_blank">http://bender.astro.sunysb.edu/random/test_0000.png</a><br clear="all"><div><br></div><div>and the script:</div>







<div><br>
</div><div><a href="http://bender.astro.sunysb.edu/random/vol_rotate.py" target="_blank">http://bender.astro.sunysb.edu/random/vol_rotate.py</a><br></div><div><br></div><div>any pointers are appreciated.</div><div><br></div>







<div>Mike</div><span><font color="#888888">
-- <br><div>Michael Zingale</div><div>Associate Professor</div><div><br></div><div>Dept. of Physics & Astronomy • Stony Brook University • Stony Brook, NY 11794-3800</div><div><i>phone</i>:  <a href="tel:631-632-8225" value="+16316328225" target="_blank">631-632-8225</a></div>







<div><i>e-mail</i>: <a href="mailto:Michael.Zingale@stonybrook.edu" target="_blank">Michael.Zingale@stonybrook.edu</a></div>
<div><i>web</i>: <a href="http://www.astro.sunysb.edu/mzingale" target="_blank">http://www.astro.sunysb.edu/mzingale</a></div>
</font></span></div></div></div></div>
<br></div></div>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Michael Zingale</div><div>Associate Professor</div><div><br></div><div>Dept. of Physics & Astronomy • Stony Brook University • Stony Brook, NY 11794-3800</div>






<div><i>phone</i>:  <a href="tel:631-632-8225" value="+16316328225" target="_blank">631-632-8225</a></div><div><i>e-mail</i>: <a href="mailto:Michael.Zingale@stonybrook.edu" target="_blank">Michael.Zingale@stonybrook.edu</a></div>





<div><i>web</i>: <a href="http://www.astro.sunysb.edu/mzingale" target="_blank">http://www.astro.sunysb.edu/mzingale</a></div>

</div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Michael Zingale</div><div>Associate Professor</div><div><br></div><div>Dept. of Physics & Astronomy • Stony Brook University • Stony Brook, NY 11794-3800</div>





<div><i>phone</i>:  <a href="tel:631-632-8225" value="+16316328225" target="_blank">631-632-8225</a></div><div><i>e-mail</i>: <a href="mailto:Michael.Zingale@stonybrook.edu" target="_blank">Michael.Zingale@stonybrook.edu</a></div>




<div><i>web</i>: <a href="http://www.astro.sunysb.edu/mzingale" target="_blank">http://www.astro.sunysb.edu/mzingale</a></div>

</div>
</div></div><br>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Michael Zingale</div><div>Associate Professor</div><div><br></div><div>Dept. of Physics & Astronomy • Stony Brook University • Stony Brook, NY 11794-3800</div>


<div><i>phone</i>:  <a href="tel:631-632-8225" value="+16316328225" target="_blank">631-632-8225</a></div><div><i>e-mail</i>: <a href="mailto:Michael.Zingale@stonybrook.edu" target="_blank">Michael.Zingale@stonybrook.edu</a></div>

<div><i>web</i>: <a href="http://www.astro.sunysb.edu/mzingale" target="_blank">http://www.astro.sunysb.edu/mzingale</a></div>

</div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Michael Zingale</div><div>Associate Professor</div><div><br></div><div>Dept. of Physics & Astronomy • Stony Brook University • Stony Brook, NY 11794-3800</div>

<div><i>phone</i>:  <a href="tel:631-632-8225" value="+16316328225" target="_blank">631-632-8225</a></div><div><i>e-mail</i>: <a href="mailto:Michael.Zingale@stonybrook.edu" target="_blank">Michael.Zingale@stonybrook.edu</a></div>
<div><i>web</i>: <a href="http://www.astro.sunysb.edu/mzingale" target="_blank">http://www.astro.sunysb.edu/mzingale</a></div>

</div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Michael Zingale</div><div>Associate Professor</div><div><br></div><div>Dept. of Physics & Astronomy • Stony Brook University • Stony Brook, NY 11794-3800</div>
<div><i>phone</i>:  631-632-8225</div><div><i>e-mail</i>: <a href="mailto:Michael.Zingale@stonybrook.edu" target="_blank">Michael.Zingale@stonybrook.edu</a></div><div><i>web</i>: <a href="http://www.astro.sunysb.edu/mzingale" target="_blank">http://www.astro.sunysb.edu/mzingale</a></div>

</div>