Help us understand the problem. What is going on with this article?

xyplotでカテゴリ描いた図の順番を逆にしたい

More than 5 years have passed since last update.

Rのlatticeパッケージのxyplotでカテゴリごと描いた図の順番を逆にしたい。
組み込みデータのairqualityを使って説明してみる。
月ごとに,温度とオゾンの散布図を描く。

library("lattice")
xyplot(Ozone ~ Temp | Month,
layout=c(1,5),
data=airquality
)

f1.jpg

この図だと,月ごとのグラフが下から上と並ぶのが気持ち悪いので,逆順にしたい。
当たり前だけど,y軸の最大値と最小値を逆にしてylimで設定したのではうまくいかない。
オプションのas.tableを使う。

xyplot(Ozone ~ Temp | Month,
layout=c(1,5),
data=airquality,
as.table=T
)

f2.jpg
逆順に並びました。
丁寧にやるなら,本当はMonthをfactorにして,levelを指定すれば良い。

月名を表示させた例は次回に。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away