3
$\begingroup$

I would like to plot a function in plane with axes grid-lines labeled as follows, $1,\sqrt{2},\sqrt{3},\sqrt{4},\sqrt{5},\ldots$, instead of the usual 1, 2, 3, 4, 5, ....

grid

$\endgroup$

closed as off-topic by Yves Klett, m_goldberg, dr.blochwave, Sjoerd C. de Vries, bbgodfrey Jun 18 '15 at 12:12

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Yves Klett, m_goldberg, dr.blochwave, Sjoerd C. de Vries, bbgodfrey
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ What is the problem with the GridLines option? This can be found directly in the help... $\endgroup$ – Yves Klett Jun 18 '15 at 9:18
  • $\begingroup$ Why not do GridLines -> {{1, Sqrt[2], (* … *)}, Automatic}? For labels, look up how to set Ticks or FrameTicks. $\endgroup$ – J. M. will be back soon Jun 18 '15 at 9:20
7
$\begingroup$

This might work for you.

ticks = 
  Module[{val},
    val = Sign[x] Sqrt[Abs[x]];
    Table[{val, Style[val, Background -> White]}, {x, -5, 5}]];
With[{max = Sqrt[6.]},
  Plot[{}, {x, -max, max},
    Ticks -> {ticks, ticks},
    PlotRange -> {{-max, max}, {-max, max}},
    AspectRatio -> Automatic,
    GridLines -> {ticks[[All, 1]], ticks[[All, 1]]}]]

grid

$\endgroup$
5
$\begingroup$

This is not ideal. The tick label overlap but perhaps it can facilitate better approaches, e.g. custom tick label placement (e.g. alternating heights, rotation etc)...

EDIT

I have removed my aesthetically poor choice of coloring but post hopefully more acceptable coloring (with aforementioned limitations):

 With[{val = Sqrt /@ Range[7], 
  lab = Style[Sqrt[#], 6, Bold, Background -> White] & /@ Range[7], 
  nlab = Style[-Sqrt[#], 6, Bold, Background -> White] & /@ Range[7], 
  tp = Table[{0, 0.02}, {14}]},
 Graphics[{LightPink, Point[{0, 0}]}, 
  PlotRange -> Table[{-3, 3}, {2}], Axes -> True, AxesStyle -> Thick, 
  Ticks -> Table[
    Transpose[{val~Join~(-val), lab~Join~nlab, tp}], {2}], 
  GridLines -> Table[val~Join~(-val), {2}], Background -> White, 
  GridLinesStyle -> Gray]]

enter image description here

$\endgroup$
  • $\begingroup$ uh, my eyes... cannot... see... colors... hurt... $\endgroup$ – Yves Klett Jun 18 '15 at 10:49
  • $\begingroup$ @YvesKlett apolgies Yves Klett...I will remove...agree ugly...probably reflects my mood...:) $\endgroup$ – ubpdqn Jun 18 '15 at 10:51
  • 2
    $\begingroup$ Don´t worry, actually that got me smiling, reminding me of those 80´s web page layouts that brought tears to many a surfer´s eye :D $\endgroup$ – Yves Klett Jun 18 '15 at 10:58
  • 1
    $\begingroup$ I must confess: I would have downvoted this if you hadn't changed the color scheme. :P $\endgroup$ – J. M. will be back soon Jun 18 '15 at 12:46
  • 2
    $\begingroup$ @J. M. let me guess... Tufte´s the word ;-) $\endgroup$ – Yves Klett Jun 18 '15 at 13:49

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