R: control scale in ggplot2's legend?

If you want to discretize the scale, it is easiest if you do change the variable (or create a new variable) and plot with that instead. Ggplot can't convert a continuous variable into a discrete one itself.

If you want to discretize the scale, it is easiest if you do change the variable (or create a new variable) and plot with that instead. Ggplot can't convert a continuous variable into a discrete one itself. Curve$games.

D str(curve) 'data. Frame': 223 obs. Of 4 variables: $ expected: int -402 -400 -391 -390 -386 -385 -383 -380 -379 -375 ... $ result : Factor w/ 194 levels "0","0,5","1",..: 3 3 3 30 2 3 2 3 3 2 ... $ games : int 1 1 1 2 1 1 2 1 1 1 ... $ colgame : Factor w/ 4 levels "0","100","5000",..: 1 1 1 1 1 1 1 1 1 1 ... Notice that result is a factor.

I presume you are using the notation where the decimal separator is a comma rather than a period. These must be converted to numbers (see further note later for a way to avoid this in the first place) curve$result ",as. Character(curve$result))) Now your graphing code would be: (I commented out the stat_function call since I don't have your function funx).

Ggplot(data=curve,aes(x = expected, y=result/games)) + geom_point(aes(x=-expected, colour=colgame)) + #stat_function(fun=funx, geom="line", col="blue") + scale_colour_discrete(name="Number of games") As to how to possibly avoid this in the first place, presuming that your read this in from a CSV file, look at read. Csv2 or the dec argument to the read. Table family of functions to specify the decimal specifier for numbers.

I am so stupid. I have just changed it in excel in order to be able to sort by numbers and by accident I must have saved it :) thanks for spotting the error! Now it works like a charm!

– mkk Oct 25 at 18:57.

If you put a reproducible example it would we easier to help. And I'm not sure to understand what you want. But some pointers to do what you want.

If you want to use breaks and to change the colours then you need to map colours to an aesthetic. Lending from Brian Diggs example: curve$games. D Lowest=TRUE) ggplot(data=curve,aes(x = expected, y=result/games, colour = games.

D)) + geom_point(aes(x=-expected)) + stat_function(fun=funx, geom="line", col="blue") + scale_colour_continuous(name="Number of games") HTH.

Having colour=games. D in the ggplot call and colour=games in the geom_point will cause problems since it is being mapped to a discrete variable in one case and a continuous one in the other. – Brian Diggs Oct 25 at 17:14 I get Warning messages: 1: In Ops.

Factor(result, games) : / not meaningful for factors 2: In Ops. Factor(result, games) : / not meaningful for factors 3: In Ops. Factor(result, games) : / not meaningful for factors – mkk Oct 25 at 17:19 @BrianDiggs, Ops, I missed that.

I'll edit the question. – lselzer Oct 25 at 17:37.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions