Make Axis and ticks invisible in mathematica plot, but keep labels -
i want make mathematica plot no visible y-axis, retaining tick labels.
i've tried axesstyle -> {thickness[.001], thickness[0]} no effect, , setting opacity 0 makes tick labels transparent (and invisible).
any appreciated...
p = plot[sin[x], {x, 0, 6 pi}, axesstyle -> {black, opacity[0]}, ticksstyle -> directive[opacity[1], black]] ticks = absoluteoptions[p, ticks]; ticks[[1, 2, 2]] = deletecases[ticks[[1, 2, 2]], {_, "", __}]; ticks[[1, 2, 2, all, 3]] = constantarray[{0, 0}, length[ticks[[1, 2, 2, all, 3]]]]; ticks[[1, 2, 2, all, 2]] = map[tostring, ticks[[1, 2, 2, all, 2]]] /. a_string :> if[stringtake[a, -1] == ".", <> "0", a]; plot[sin[x], {x, 0, 6 pi}, axesstyle -> {black, directive[opacity[0], red]}, ticksstyle -> directive[opacity[1], black], ticks -> {automatic, ticks[[1, 2, 2]]}]
to exact original ticks can use
cases[charting`findticks[{0, 1}, {0, 1}] @@ plotrange[p][[2]], {_, _}]
{{-1.,-1.0},{-0.5,-0.5},{0.,0},{0.5,0.5},{1.,1.0}}
as implemented here:
p = plot[sin[x], {x, 0, 6 pi}, axesstyle -> {automatic, opacity[0]}, ticksstyle -> opacity[1]]; ticks = absoluteoptions[p, ticks]; onestyledtick = ticks[[1, 2, 2, 1]]; labels = cases[charting`findticks[{0, 1}, {0, 1}] @@ plotrange[p][[2]], {_, _}]; yticks = map[join[#, {{0, 0}}, take[onestyledtick, -1]] &, labels]; plot[sin[x], {x, 0, 6 pi}, axesstyle -> {automatic, opacity[0]}, ticksstyle -> opacity[1], ticks -> {automatic, yticks}]
Comments
Post a Comment