Spineplot wishlist

オープン
#660 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
静か
技術スタック
r

調査の方向性

エントリーポイントの type_spineplot() から始め、issue にある tinyplot() の例を再現し、base R の spineplot() および mosaicplot() と比較してください。実装を変更する前に、境界線の扱い、by 変数、グレーの連続色に関する未解決の設計上の問題を解決してください。要求された表示と色の挙動が合意した例と一致すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Disclaimer: I have collected a few issues that could be improved in spineplots, some of which were already discussed in #657. I'm happy to start addressing the issues but would appreciate some guidance/feedback first. This can easily wait until after the summer vacation!

Border color

In #657 spineplots received border = par("fg") as the border color rather than border = icol. Wouldn't the latter be more consistent, e.g., with boxplot? Also, I think that this means that the border color cannot be set as an argument to tinyplot(...) or type_spineplot(...).

My suggestion would be to export a border = NULL argument in type_spineplot(). Possibly additionally switch to border = icol internally when the user specifies border = "by"?

As an illustration we can use the following code. The first plot shows the current border = par("fg") and the latter shows what we would get with border = icol.

tinyplot(species ~ bill_dep | sex, facet = "by", data = penguins, legend = FALSE, theme = "clean2")
Image Image

by variable

The current implementation of the by variable was always just a poor interim solution which was only marginally better than saying that by was not supported.

The natural strategy would be to simply add further vertical splits for the by variable (in addition to the x variable). The basic idea is straightforward and can be approximated by using interaction(x, by).

ucb = as.data.frame(UCBAdmissions)
tinyplot(Admit ~ interaction(Gender, Dept, sep = "\n"), data = ucb, weights = Freq)
Image

However, the spacing (tol) should be improved and it would also be possible to get nicer axis labels. This could be similar to what mosaicplot() in base R does:

mosaicplot(aperm(UCBAdmissions, 3:1), dir = c("v", "v", "h"), off = c(6, 3, 0), col = gray.colors(2, rev = TRUE), main = "")
Image

An open question is whether this display should be produced with Gender as the by variable (i.e., Admit ~ Dept | Gender) or with Dept (i.e., Admit ~ Gender | Dept). For categorical x variables like here, I would find Gender as the by variable a bit more intuitive. However, it wouldn't look good to use the same display for a numeric x variable. So I think we should go with Dept as the by variable here.

Note that the display is similar to but not quite the same as the corresponding faceted display below. The crucial difference is that in the faceted display every Dept gets the same size for the facet. In contrast in the by display you should be able to see the marginal distribution of Dept as well, e.g., that there are more observations in department A than in department B.

tinyplot(Admit ~ Gender, data = ucb, facet = 1 ~ Dept, weights = Freq)
Image

Black-based gray sequential colors

In the single-group case the sequential palette constructed from black is actually set up via gray.colors() to match what base R does in spineplot().

However, in the multi-group case the same is not done. See the left group below which really uses full black as the base color which is probably a bit too "heavy". Switching to gray.colors() here would also work better.

tinyplot(Admit ~ Gender | Dept, data = ucb, facet = 1 ~ Dept, weights = Freq)
Image
主要言語
R
スター
430
フォーク
24
平均マージ
14時間 17分
マージ済み PR(30日)
8

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

grantmcdermott/tinyplot のほかの issue

grantmcdermott/tinyplot の issue をすべて見る

似ている issue

R の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。