Ggplot2 တွင် geom_hline သို့ အညွှန်းတစ်ခုထည့်နည်း


ggplot2 တွင် အညွှန်းတစ်ခုအား အလျားလိုက်မျဉ်းတစ်ခုသို့ထည့်ရန် အောက်ပါအခြေခံအထားအသိုကိုသုံးနိုင်သည်။

 + annotate(" text ", x= 9 , y= 20 , label=" Here is my text ")

အောက်ဖော်ပြပါ ဥပမာများသည် ဤ syntax ကို လက်တွေ့တွင် မည်သို့အသုံးပြုရမည်ကို ပြသထားသည်။

ဥပမာ 1- geom_hline သို့ အညွှန်းတစ်ခုထည့်ပါ။

အောက်ပါကုဒ်သည် ggplot2 တွင် အညွှန်းတစ်ခုအား အလျားလိုက်မျဉ်းတစ်ခုသို့ မည်သို့ထည့်ရမည်ကို ပြသသည်-

 library (ggplot2)

#create data frame 
df <- data. frame (x=c(1, 3, 3, 4, 5, 5, 6, 9, 12, 15),
                 y=c(13, 14, 14, 12, 17, 21, 22, 28, 30, 31))

#create scatterplot with horizontal line at y=20
ggplot(df, aes(x=x, y=y)) +
geom_point() +
  geom_hline(yintercept= 20 ) +
  annotate("text", x= 9 , y= 20.5 , label=" Some text ") 

ggplot2 တွင် geom_hline သို့ အညွှန်းထည့်ပါ။

ဥပမာ 2- geom_hline သို့ စိတ်ကြိုက်တံဆိပ်တစ်ခု ထည့်ပါ။

အောက်ပါကုဒ်သည် ggplot2 ရှိ အလျားလိုက်မျဉ်းတစ်ခုသို့ စိတ်ကြိုက် အရွယ်အစား နှင့် အရောင် ပါသော အညွှန်းတစ်ခုထည့်ရန် အရွယ်အစားနှင့် အရောင်အငြင်းအခုံများကို မည်သို့အသုံးပြုရမည်ကို ပြသသည်-

 library (ggplot2)

#create data frame 
df <- data. frame (x=c(1, 3, 3, 4, 5, 5, 6, 9, 12, 15),
                 y=c(13, 14, 14, 12, 17, 21, 22, 28, 30, 31))

#create scatterplot with horizontal line at y=20
ggplot(df, aes(x=x, y=y)) +
geom_point() +
  geom_hline(yintercept= 20 ) +
  annotate("text", x= 10 , y= 21.5 , label=" Some text ", size= 15 , color=" blue ") 

ဥပမာ 3- geom_hline သို့ အညွှန်းများစွာထည့်ပါ။

အောက်ဖော်ပြပါကုဒ်သည် ggplot2 ရှိ အညွှန်းများစွာကို အလျားလိုက်မျဉ်းတစ်ခုသို့ ပေါင်းထည့်ရန် annotate() လုပ်ဆောင်ချက်ကို အကြိမ်များစွာ အသုံးပြုရပုံကို ပြသသည်-

 library (ggplot2)

#create data frame 
df <- data. frame (x=c(1, 3, 3, 4, 5, 5, 6, 9, 12, 15),
                 y=c(13, 14, 14, 12, 17, 21, 22, 28, 30, 31))

#create scatterplot with horizontal line at y=10
ggplot(df, aes(x=x, y=y)) +
geom_point() +
  geom_hline(yintercept= 20 ) +
  annotate("text", x= 10 , y= 19 , label=" Some text ", size= 15 , color=" blue ") +
  annotate("text", x= 10 , y= 21 , label=" More text ", size= 9 , color=" red ") 

သင်ဇာတ်ကွက်တွင် အညွှန်းများထည့်လိုသည့်အတိုင်း annotate() လုပ်ဆောင်ချက်ကို အကြိမ်များစွာ အသုံးပြုရန် အားမနာပါ။

ထပ်လောင်းအရင်းအမြစ်များ

အောက်ဖော်ပြပါ သင်ခန်းစာများသည် ggplot2 တွင် အခြားဘုံအလုပ်များကို မည်သို့လုပ်ဆောင်ရမည်ကို ရှင်းပြသည်-

ggplot2 တွင် geom_vline သို့ အညွှန်းတစ်ခုထည့်နည်း
ggplot2 တွင် ပျမ်းမျှမျဉ်းကြောင်းထည့်နည်း
ggplot2 တွင် မျဉ်းအရောင်များ ပြောင်းနည်း

မှတ်ချက်တစ်ခုထည့်ပါ။

သင့် email လိပ်စာကို ဖော်ပြမည် မဟုတ်ပါ။ လိုအပ်သော ကွက်လပ်များကို * ဖြင့်မှတ်သားထားသည်