2
$\begingroup$

Is it possible to add hyperlinks to a plot? As in, If I have a list of points and I want to link each of those points to a different reference which can be clicked and opened. Is it do-able?

$\endgroup$

3 Answers 3

5
$\begingroup$

Try this:

ListPlot[Table[Hyperlink[{i, i}, "http://www.wolfram.com"], {i, 2}]]

yielding the plot

enter image description here

The plot itself and each its point opens the Wolfram site by click.

This example shows how to create the plot in which different points open different sites.

ListPlot[{Hyperlink[{1, 1}, "http://www.wolfram.com"], 
  Hyperlink[{2, 2}, "https://www.google.de/"]}]

If you need to open a notebook or to pass to a certain cell within the present notebook, the technique is the same. Have a look at Menu/Help/WolframDocumentation/Hyperlink.

You might also think about wrapping the point by the Button command. The button may be made such that the button itself is invisible, only the point being visible. The button may activate opening a file, calling the necessary cite, showing the desired value, and other actions of your wish.

Have fun!

$\endgroup$
2
  • $\begingroup$ This method works but when I export the plot as pdf or copy the plot in lets say powerpoint, the hyperlinks don't work anymore. Is there some way to make the hyperlinks work even when exported? $\endgroup$ Feb 18, 2022 at 18:01
  • $\begingroup$ I do not think that it is possible. hyperlink in a notebook is a functionality of Mma. I do not think that it survives the transformation nb->pdf. It will work after transformation nb->cdf, however. $\endgroup$ Feb 18, 2022 at 19:12
4
$\begingroup$

You can use a hyperlink with Callout.

ListPlot[{{2.5, 1.7} (*other pts*)
  , Callout[{1, 1}
   , Hyperlink[Style["\[WolframLanguageLogo]", Red, 18, Bold], 
    URL["www.wolfram.com"]], Above]
  , Callout[{2, 2}
   , Hyperlink[Style["Wordle", Gray, 12], 
    URL["https://www.nytimes.com/games/wordle/index.html"]], Above]
  }
 , PlotRange -> {{-0.5, 3}, {-0.2, 2.5}}
 , AspectRatio -> 1
 ]

enter image description here

$\endgroup$
2
  • $\begingroup$ Awesome! Didn't know about the callout feature. I had a stupid question though, What is the way to selectively change the shape and color of each point in list plot? Let's say I want the first point to be a black square and the second point to be a red circle etc.? $\endgroup$ Feb 18, 2022 at 16:32
  • $\begingroup$ Please start a fresh question. I think you can do this with PlotMarkers although these are assigned to an entire set of points. Transposing the lists and assigning separate markers would do the trick. There are, always, many ways to do anything in Mma. $\endgroup$
    – Syed
    Feb 18, 2022 at 16:36
3
$\begingroup$

Combining with Tooltip

f[x_] := 4*x - 4*x^2 - x^3 + x^4

xmin = -2.5; xmax = 2.5;

roots = Solve[{f[x] == 0, xmin <= x <= xmax}, x, Reals];

argmax = Solve[{f'[x] == 0, f''[x] < 0, xmin <= x <= xmax}, x];

argmin = Solve[{f'[x] == 0, f''[x] > 0, xmin <= x <= xmax}, x];

Legended[
 Plot[f[x], {x, xmin, xmax},
  PlotStyle -> ColorData[97][2],
  Epilog -> {AbsolutePointSize[6],
    Green,
    Hyperlink[
       Tooltip[Point[{x, f[x]}], {x, f[x]}] /. N[#],
       "https://en.wikipedia.org/wiki/Zero_of_a_function"] & /@ 
     roots,
    Blue,
    Hyperlink[
       Tooltip[Point[{x, f[x]}], {x, f[x]}] /. N[#],
       "https://en.wikipedia.org/wiki/Maxima_and_minima"] & /@
     argmin,
    Red,
    Hyperlink[
       Tooltip[Point[{x, f[x]}], {x, f[x]}] /. N[#],
       "https://en.wikipedia.org/wiki/Maxima_and_minima"] & /@
     argmax}],
 PointLegend[{Red, Green, Blue}, {"local maximum", "root", 
   "local minimum"}]]

enter image description here

$\endgroup$
1
  • $\begingroup$ This method works but when I export the plot as pdf or copy the plot in lets say powerpoint, the hyperlinks don't work anymore. Is there some way to make the hyperlinks work even when exported? $\endgroup$ Feb 18, 2022 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.