Hello there,
yes, along those lines one can draw everything oneself, e.g.:
my_data <- data.frame(a = 1:12, b = -2:9)
p <- ggplot(my_data, aes(x = a, y = b)) +
geom_point() +
geom_smooth(method = lm, se = FALSE, colour = "black", size = 0.70) +
scale_x_continuous(breaks = seq(0, 12, 1))
yax <- data.frame(y = seq(0, max(my_data$a), by =
floor(diff(range(my_data$a))/5)),
x = 0, xend = -0.3)
yax$yend <- yax$y
xax <- data.frame(x = seq(0, max(my_data$a), by =
floor(diff(range(my_data$b))/5)),
y = 0, yend = -0.5)
xax$xend <- xax$x
p +
theme(axis.text = element_blank(), axis.ticks = element_blank(),
axis.title = element_blank()) +
## Lines
geom_segment(aes(x = 0, y = 0, xend = max(x), yend = 0), xax) +
geom_segment(aes(x = 0, y = 0, xend = 0, yend = max(y)), yax) +
## ticks
geom_segment(aes(x = x, y = y, xend = xend, yend = yend), yax) +
geom_segment(aes(x = x, y = y, xend = xend, yend = yend), xax) +
## axis labels
geom_text(aes(x = x, y = yend + -0.3, label = x), xax) +
geom_text(aes(x = xend + -0.1, y = y, label = y), yax)
This plot looks like crap. One could package all that crap code into a
function, which is a mighty crappy idea. I am guessing there is a regent
of crapdom who holds the authority to request such crap. Crapdom needs a
new regent.
Crappy greetings
Brian
On 06/16/2016 10:05 AM, sanmohan wrote:
> A slight modification to my previous solution: if you want the x-axis to
> start at 0, then you will need to use geom_segement instead of geom_hline.
>
> my_data <- data.frame(a = 1:12, b = -2:9)
>
> p <- ggplot(my_data, aes(x = a, y = b)) +
> geom_point() +
> geom_smooth(method = lm, se = FALSE, colour = "black", size = 0.70) +
> scale_x_continuous(breaks = seq(0, 12, 1))
>
> p+theme_classic()+theme(axis.text=element_blank(),axis.ticks=element_blank(),axis.title=element_blank())+geom_segment(aes(x=0,y=0,xend=12,yend=0))+geom_vline(xintercept
> =
> 0)+geom_segment(aes(x=2,y=0,xend=2,yend=-.3))+geom_text(aes(x=2,y=-.5,label='2'))+geom_segment(aes(x=0,y=2,xend=-.3,yend=2))+geom_text(aes(x=-.5,y=2,label='2'))
>
> <
https://lh3.googleusercontent.com/-YNkQcvWWFco/V2JdkoCLEnI/AAAAAAAAA_8/YoCj0sp5mQ0DZPjSItVsFTIDmQJg0tSSQCLcB/s1600/Rplot.png>
>>> To post: email
ggp...@googlegroups.com <javascript:>
>>> To unsubscribe: email
ggplot2+u...@googlegroups.com <javascript:>
>>> More options:
http://groups.google.com/group/ggplot2
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>> Groups
>>> "ggplot2" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>> an
>>> email to
ggplot2+u...@googlegroups.com <javascript:>.