Hi Jim,

Thank you very much. I have started another conversation in the ggplot
list. My current code is

 plot_data <- data.frame(

xmin = c(1, 1.5, 3, 3.5, 5, 5.5, 7, 7.5, 9, 9.5, 11, 11.5, 13, 13.5)

, ymin = c(16.7026, 17.20, 14.9968, 16.32, 16.0630, 15.86, 17.7510, 18.12,
-5.01694, -8.86, -.44146, -0.03, 1.45884, 0.95)

, ymax = c(21.1602, 20.12, 18.7613, 18.60, 19.1367, 18.14, 23.6730, 22.29,
2.26564, 3.03, 3.08630, 3.57, 3.39865, 2.81)

, model = rep(c("MMNL", "GMNL"), 7)

)


 plot_data$"xmax" <- plot_data$"xmin" + 1


 WTP_plot_parallel <- ggplot(plot_data, aes(xmin = xmin, xmax = xmax, ymin
= ymin, ymax = ymax, fill = model)) +

geom_rect(alpha = .8) +

scale_x_continuous(breaks = c(1.5, 3.5, 5.5, 7.5, 9.5, 11.5, 13.5)

, labels = c("Wild cod", "Farmed cod", "Farmed salmon", "Wild monk",
"Farmed pangasius", "MSC label", "AB label")) +

scale_y_continuous(name = "Confidence Interval of WTP Estimators (EUR/KG)")
+

theme(axis.text.x = element_text(angle = 45, hjust = .5, vjust = .5)) +

scale_fill_manual("Model", values = c(grey(0.1), grey(0.7)))


 WTP_plot_parallel

I'm still working on some details. If you are interested, I'll keep you in
the loop.

Kind regards,
Xianwen
--
Xianwen Chen <xnwncn@gmail.com>
Graduate student of economics
Norwegian University of Life Sciences


On Tue, May 21, 2013 at 12:40 AM, Jim Lemon <jim@bitwrit.com.au> wrote:

> On 05/21/2013 12:54 AM, Xianwen Chen wrote:
>
>> Hi Jim,
>>
>> Thank you for the suggestion. I think overlapped rectangles will well
>> present the message. I'm now trying ggplot2.
>>
>> Here is the code:
>>
>> require(ggplot2)
>> rect_MNL_Delta <- data.frame(
>> xmin <- c(1, 3, 5, 7, 9, 11, 13),
>> xmax <- xmin + 1,
>> ymin <- c(16.7026, 14.9968, 16.0630, 17.7510, -5.01694, -.44146, 1.45884),
>> ymax <- c(21.1602, 18.7613, 19.1367, 23.6730, 2.26564, 3.08630, 3.39865)
>> )
>> rect_GMNL <- data <- data.frame(
>> xmin <- c(1, 3, 5, 7, 9, 11, 13),
>> xmax <- xmin + 1,
>> ymin <- c(17.20, 16.32, 15.86, 18.12, -8.86, -0.03, 0.95),
>> ymax <- c(20.12, 18.60, 18.14, 22.29, 3.03, 3.57, 2.81)
>> )
>>
>> ggplot() +
>> geom_rect(data = rect_MNL_Delta, aes(xmin = xmin, xmax = xmax, ymin =
>> ymin, ymax = ymax), fill = "blue", alpha = 0.1) +
>> geom_rect(data = rect_GMNL, aes(xmin = xmin, xmax = xmax, ymin = ymin,
>> ymax = ymax), fill = "green", alpha = 0.1)
>>
>> The problem is that the second geom_rect() fully covered the first
>> geom_rect(), instead of overlapping. Another issue is that I don't know
>> how to set labels on x-axis, instead of the current ticks. I would like
>> to have for instance 'Farmed cod' under the first rectangle.
>>
>>  Hi Xianwen,
> The problem with the overlapping is in the last two lines. These should
> read:
>
>         geom_rect(data = rect_MNL_Delta, aes(xmin = rect_MNL_Delta$xmin,
> xmax = rect_MNL_Delta$xmax, ymin = rect_MNL_Delta$ymin, ymax =
> rect_MNL_Delta$ymax), fill = "blue", alpha = 0.1) +
>         geom_rect(data = rect_GMNL, aes(xmin = rect_GMNL$xmin, xmax =
> rect_GMNL$xmax, ymin = rect_GMNL$ymin, ymax = rect_GMNL$ymax), fill =
> "green", alpha = 0.1)
>
> I am not terribly familiar with ggplot, but you should be able to get
> custom tick labels on your horizontal axis. I have to go out now, but when
> I return I'll have a look at the "scale" functions, as I think this is
> hiding in there.
>
> Jim
>

	[[alternative HTML version deleted]]

