非常に素朴なアプローチは、たとえばgeom_rect()
を使用してキーボードを単純に描くことです。 最初の手順は、各行を作成することです。別々に行ったのは、本当に簡単に紛失しないようにするためです。 キーを別の値に変更することは、各データフレーム内で簡単に特定できるため、非常に簡単です。
library(ggplot2)
#1st line from top
df1=data.frame(xmin=c(0,1,2,3,4,5,6,7,8,9,10,11,12,13),
xmax=c(1,2,3,4,5,6,7,8,9,10,11,12,13,15),
ymin=rep(4,14),
ymax=rep(5,14),
value=c("'","1","2","3","4","5","6","7","8","9","0","-","=","backspace"))
#2nd line from top
df2=data.frame(xmin=c(0,1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5,11.5,12.5,13.5),
xmax=c(1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5,11.5,12.5,13.5,15),
ymin=rep(3,14),
ymax=rep(4,14),
value=c("tab","Q","W","E","R","T","Y","U","I","O","P","[","]","enter"))
#3rd line from top
df3=data.frame(xmin=c(0,1.75,2.75,3.75,4.75,5.75,6.75,7.75,8.75,9.75,10.75,11.75,12.75,13.75),
xmax=c(1.75,2.75,3.75,4.75,5.75,6.75,7.75,8.75,9.75,10.75,11.75,12.75,13.75,15),
ymin=rep(2,14),
ymax=rep(3,14),
value=c("caps","A","S","D","F","G","H","J","K","L",":","@","~","enter"))
#4th line from top
df4=data.frame(xmin=c(0,1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5,11.5,12.5),
xmax=c(1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5,11.5,12.5,15),
ymin=rep(1,13),
ymax=rep(2,13),
value=c("shiftr","|","Z","X","C","V","B","N","M","<",">","?","shiftr"))
#5th line from top
df5=data.frame(xmin=c(0,1.5,2.5,4,10,11.5,12.5,13.5),
xmax=c(1.5,2.5,4,10,11.5,12.5,13.5,15),
ymin=rep(0,8),
ymax=rep(1,8),
value=c("ctrll","winl","altl","space","altgr","winr","menu","ctrlr"))
#putting it together
df=rbind(df1,df2,df3,df4,df5)
ggplot(df,aes(xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax))+
geom_rect(colour="black")+geom_text(aes(x=(xmin+xmax)/2,y=(ymin+ymax)/2,label=value))+
theme_void()
![enter image description here](https://i.stack.imgur.com/fVfVb.png)
注:これは、はるかに完璧からである(「Enter」キーを2に分割される)が、それはあなたにいくつかのアイデアや上で動作するようにベースを与えるかもしれません。
あなたはおそらく、単にそのPNG画像をプロットし、その上にいくつかの余分なラベルをプロットするのが最も良いでしょう。また、異なるユーザーが異なるキーボードレイアウトを持っていることにも注意してください。 – Axeman