3
$\begingroup$

I have a list of pairs of values that I am plotting in a ListLinePlot. I can use the tooltip functionality fine but I want to stop them from displaying in scientific notation. I have tried the following

  DisplayData20Yr = {{2010, 1.49952026`*^6}, {2011, 
   1.82272254`*^6}, {2012, 2.01921445`*^6}, {2013, 
   2.28115586`*^6}, {2014, 2.77986072`*^6}, {2015, 
   3.18915846`*^6}, {2016, 3.1505870500000003`*^6}, {2017, 
   3.44300142`*^6}, {2018, 3.58399037`*^6}, {2019, 
   3.67522613`*^6}, {2020, 3.88522079`*^6}, {2021, 
   3.90061335`*^6}, {2022, 3.9293277800000003`*^6}, {2023, 
   3.90820965`*^6}, {2024, 3.9495397`*^6}, {2025, 
   3.6954160300000003`*^6}, {2026, 3.76539612`*^6}, {2027, 
   3.77579118`*^6}, {2028, 3.29648289`*^6}, {2029, 
   1.6678326400000001`*^6}}

DisplayData20YrNoScientific = 
  Map[NumberForm[N[#], ExponentFunction -> (Null &)] &, 
   DisplayData20Yr];

ListLinePlot[Tooltip[Table[DisplayData20Yr[[i]], {i, 20}]], 
  Joined -> True, PlotMarkers -> {Automatic, 12}];

ListLinePlot[Tooltip[DisplayData20Yr], Joined -> True, 
  PlotMarkers -> {Automatic, 12}];

ListLinePlot[
  Tooltip[DisplayData20Yr, Table[DisplayData20Yr[[i]], {i, 20}]], 
  Joined -> True, PlotMarkers -> {Automatic, 12}];

The first plot works normally with the tooltips showing in scientific notation. The second plot works in the same way as the first plot. The third plot doesn't disply tooltips at all. When I then use the DisplayData20YrNoScientific data set all three plot do not display anything at all. No lines/points or tooltips. They are blank. In my understanding the third plot should work because tooltip can be used as Tooltip[expression,label].

$\endgroup$
5
$\begingroup$

What you need is:

DisplayData20YrNoScientific = 
 Map[Tooltip[#, NumberForm[N[#], ExponentFunction -> (Null &)]] &, DisplayData20Yr]

So check that the tooltip works ok on the data:

enter image description here

Then plot it:

ListLinePlot[DisplayData20YrNoScientific, Joined -> True, 
 PlotMarkers -> {Automatic, 12}]

enter image description here

Edit

Forgot to mention that your original DisplayData20YrNoScientific

DisplayData20YrNoScientific = 
  Map[NumberForm[N[#], ExponentFunction -> (Null &)] &, 
   DisplayData20Yr];

creates a list of strings so there is nothing for ListLinePlot to plot which is why it fails.

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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