0
$\begingroup$

This question already has an answer here:

I have some data which i inter alia define and invert

dataYAG = {{0.0095, 25.07}, {0.05, 50.1}, {0.1, 58.7}, {0.2, 65.01}, {0.3, 66.8}, {0.4, 66.97}};


InvYAG = (dataYAG/100)^-1

which i plot than with usage of the customticks package

with

dataPlotYAG = 
ListPlot[InvYAG, PlotRange -> {{0, 12000}, {1, 5}}, 
Frame -> True,                      
FrameTicks -> {LinTicks[0, 12000, TickDirection -> Out, 
MajorTickLength -> 0.02, MinorTickLength -> 0.01, 
TickLabelFunction ->Function[x,Framed[If[Boole[IntegerQ[x/10000]] == 0, N[x/10000],IntegerPart[x/10000]], FrameStyle -> None]]], 
LinTicks[1, 5, TickDirection -> Out, MajorTickLength -> 0.02, 
MinorTickLength -> 0.01,TickLabelFunction -> (Framed[#2, FrameStyle -> None] &)], None,None}, FrameStyle -> Directive[Thickness[.003], Black]
        ]

i tried the condition

If[Boole[IntegerQ[x/10000]] == 0, N[x/10000], IntegerPart[x/10000]

to get rid of that, what obviously does not work.

enter image description here

Is this because x is not evaluated in my options so i run of course never in my conditions and is there a way to get rid of that points ? (which would of course only take me some seconds in illustrator)?

Cheers

$\endgroup$

marked as duplicate by Jens, MarcoB, b.gates.you.know.what, m_goldberg, J. M. will be back soon Aug 12 '15 at 12:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    $\begingroup$ To get rid of what? You do not describe clearly what you are trying to achieve. $\endgroup$ – Oleksandr R. Aug 11 '15 at 19:45
  • $\begingroup$ Sorry, i forgot actually to point out that I tried to get rid of the decimal point for "0." and "1" $\endgroup$ – Bastian Aug 11 '15 at 22:29
0
$\begingroup$

It seems needlessly complex to write

If[Boole[IntegerQ[x/10000]] == 0, N[x/10000], IntegerPart[x/10000]

when

If[IntegerQ[x/10000], IntegerPart[x/10000], N[x/10000] ]

would do. (Notice that the arguments are reversed because you are now checking if IntegerQ is true, not false.)

I do not have the customticks package, but I suspect your problem is that you have defined a pure function (Function) without a terminating &. Try this Slot-notation version, with the terminating & and see if that helps.

Framed[If[IntegerQ[#/10000], IntegerPart[#/10000], N[#/10000]] & 

You might also want to consider whether there are small rounding issues in your data, so that

Framed[If[IntegerQ[Chop[#/10000]], IntegerPart[#/10000], N[#/10000]] & 

gets the result you want. You could also try Round or Floor instead of IntegerPart.

If you need something more sophisticated you could write a custom function like this one. In your case you would change the n to n/10000, or include a second argument that defines the denominator. You could also do this as an If rather than a Switch: it's in that form because the previous version of this function was more complicated.

numberformat[n_?NumericQ, opts:OptionsPattern[{NumberForm}]]:= 
  Switch[n, _Integer, NumberForm[n, Sequence@@FilterRules[{opts}, 
   Options[NumberForm]], DigitBlock -> 3, NumberSeparator -> "\[ThickSpace]"],
      _,  NumberForm[Chop@N[n], Sequence@@FilterRules[{opts}, Options[NumberForm]]] ]
$\endgroup$

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