Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Bug: ListPlot and Tooltip

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102585] Re: Bug: ListPlot and Tooltip
  • From: Jens <noeckel at gmail.com>
  • Date: Sat, 15 Aug 2009 05:34:48 -0400 (EDT)
  • References: <h5bk30$hja$1@smc.vnet.net> <h5jdkb$1a2$1@smc.vnet.net>

On Aug 14, 3:00 am, dr DanW <dmaxwar... at gmail.com> wrote:
> Perhaps calling it a bug was too strong; there is a discrepancy in the
> behavior of ListPlot and ListLogPlot.
>
> In ListLogPlot, Tooltip wraps the entire dataset:
>
> In[1]: InputForm[ ListLogPlot[ Tooltip[ Range[4], "Data" ] ] ]
>
> Out[1]: Graphics[{{{}, Tooltip[{Hue[0.67, 0.6, 0.6], Point[{{1., 0.},
> {2.,
>       0.6931471805599453}, {3., 1.0986122886681098}, {4.,
>       1.3862943611198906}}]}, "Data"]...
>
> However, if I use ListPlot instead, I loose Tooltip entirely
>
> In[2]: InputForm[ ListPlot[ Tooltip[ Range[4], "Data" ] ] ]
>
> Out[2]: Graphics[{Hue[0.67, 0.6, 0.6], Point[{{1., 1.}, {2., 2.}, {3.,
> 3.}, {4., 4.}}]}...
>
> After having successfully used Tooltip with ListLogPlot for many
> months, it was quite a surprise to have my tooltips disappear just
> because I changed my x-axis scale.
>
> I have seen several discussions on this group on the nature of the
> term "bug", and I don't really want to start another one.  I have
> learned high standards from Mathematica.  One of its basic tenets is
> "if it works at all, it works everywhere".  This has caused me to
> expect that if I see tooltips in ListLogPlot, I should see them in
> ListPlot.
>
> So, I am not looking for a solution here.  I'm already aware that I
> can map Tooltip onto individual data points.  I only posted this "bug"
> to let the people who want to use my legend workaround that it is not
> going to work with ListPlot.
>
> Daniel

On Aug 14, 3:00 am, dr DanW <dmaxwar... at gmail.com> wrote:
> Perhaps calling it a bug was too strong; there is a discrepancy in the
> behavior of ListPlot and ListLogPlot.
>
> In ListLogPlot, Tooltip wraps the entire dataset:
>
> In[1]: InputForm[ ListLogPlot[ Tooltip[ Range[4], "Data" ] ] ]
>
> Out[1]: Graphics[{{{}, Tooltip[{Hue[0.67, 0.6, 0.6], Point[{{1., 0.},
> {2.,
>       0.6931471805599453}, {3., 1.0986122886681098}, {4.,
>       1.3862943611198906}}]}, "Data"]...
>
> However, if I use ListPlot instead, I loose Tooltip entirely
>
> In[2]: InputForm[ ListPlot[ Tooltip[ Range[4], "Data" ] ] ]
>
> Out[2]: Graphics[{Hue[0.67, 0.6, 0.6], Point[{{1., 1.}, {2., 2.}, {3.,
> 3.}, {4., 4.}}]}...
>
> After having successfully used Tooltip with ListLogPlot for many
> months, it was quite a surprise to have my tooltips disappear just
> because I changed my x-axis scale.
>
> I have seen several discussions on this group on the nature of the
> term "bug", and I don't really want to start another one.  I have
> learned high standards from Mathematica.  One of its basic tenets is
> "if it works at all, it works everywhere".  This has caused me to
> expect that if I see tooltips in ListLogPlot, I should see them in
> ListPlot.
>
> So, I am not looking for a solution here.  I'm already aware that I
> can map Tooltip onto individual data points.  I only posted this "bug"
> to let the people who want to use my legend workaround that it is not
> going to work with ListPlot.
>
> Daniel

Hi,
if it's not a bug, it certainly is an inconsistency from the user's
point of view.
I use a different approach to make custom legends. The problem of
extracting line styles from the plot really only becomes important
when you're using the default styles. If the plot defines its own
styles then you already have that information somewhere and don't need
the Tooltip to extract it. So given that you're using the Mathematica
defaults, I make the (empirically tested) additional assumption that
these defaults are reproducible and identical for all types of plots
(including ListLogPlot). Then I can get a list of these defaults by
making the simplest possible plot with the same number of data sets as
in the plot of interest, and extract the styles from this simple plot
in a hard-coded way.
Here is a function to do that:

markerSymbols[n_] :=
 Drop[Drop[
    ListPlot[Transpose[{Range[n]}], PlotMarkers -> Automatic][[1, 2,
      1]], -1] /. Inset[x_, i__] :> Inset[x, {0, 0}], None, -1]

It gives you both, the colors and the marker symbols, as a list that
can be re-used in all plots without having to be re-evaluated
repeatedly. If you don't need the list of markers, just drop them from
the list. I have an example of how to use this in plot legends on my
notes page:
http://www.uoregon.edu/~noeckel/MathematicaGraphics.html#PlotMarkers

Regards,
Jens


  • Prev by Date: Re: Problem with a 1st order IV ODE (nonlinear)
  • Next by Date: Re: Re: publicon
  • Previous by thread: Re: Bug: ListPlot and Tooltip
  • Next by thread: Re: Bug: ListPlot and Tooltip