如何在多個圖中選擇一個要編輯的圖? (How to select one plot to be edit in multiple plots?)


問題描述

如何在多個圖中選擇一個要編輯的圖? (How to select one plot to be edit in multiple plots?)

我試圖在一張圖片中繪製兩個圖並編輯兩個圖的 x 和 y 軸。但我只能編輯右邊的情節。我無法編輯左側的情節。命令如下:

#divide ploting area in one row and two columns:
par(mfrow=c(1,2))
#plot the two graphics already with the same y limits:
plot(Age[Gender=="male"], Height[Gender=="male"], las = 1, main = "Age x Height for Males", xlab = "Age", ylab = "Height", ylim = c(45,85), axes = F)
plot(Age[Gender=="female"], Height[Gender=="female"], las = 1, main = "Age x Height for Females", xlab = "Age", ylab = "Height", ylim = c(45,85), axes = F)
#edit the "x" axis
axis(side=1, at = c(3, 6, 10), labels = c("3", "6", "10"))

這就是我得到的:第二個圖形的“x”軸已被編輯,我無法返回第一個繪圖。

在此處輸入圖片描述


參考解法

方法 1:

As user20650 stated: call your edits after each plot command. In your case:

par(mfrow=c(1,2))
plot(Age[Gender=="male"], Height[Gender=="male"], las = 1, main = "Age x Height for Males", xlab = "Age", ylab = "Height", ylim = c(45,85), axes = F)
axis(side=1, at = c(3, 6, 10), labels = c("3", "6", "10"))
plot(Age[Gender=="female"], Height[Gender=="female"], las = 1, main = "Age x Height for Females", xlab = "Age", ylab = "Height", ylim = c(45,85), axes = F)
axis(side=1, at = c(3, 6, 10), labels = c("3", "6", "10"))

(by BCArgrosapluesch)

參考文件

  1. How to select one plot to be edit in multiple plots? (CC BY‑SA 2.5/3.0/4.0)

#scatter-plot #R #plot






相關問題

matplotlib:重繪前清除散點數據 (matplotlib: clearing the scatter data before redrawing)

使用 matplotlib 保存散點圖動畫 (Saving scatterplot animations with matplotlib)

在 matplotlib 中圍繞散點圖中的數據點繪製平滑多邊形 (draw a smooth polygon around data points in a scatter plot, in matplotlib)

Java:非常簡單的散點圖實用程序 (Java: Really simple scatter plot utility)

如何在多個圖中選擇一個要編輯的圖? (How to select one plot to be edit in multiple plots?)

d3js散點圖自動更新不起作用 (d3js scatter plot auto update doesnt work)

散點圖中的重疊趨勢線,R (Overlapping Trend Lines in scatterplots, R)

DC.JS 散點圖選擇 (DC.JS scatterplot chart selection)

固定散景散點圖中的軸間距(刻度) (Fixing axis spacing (ticks) in Bokeh scatter plots)

如何在顏色條上繪製散點圖? (How to plot scatter plot points on a colorbar?)

如何在散點圖中以均勻間隔更改 x 軸值? (How to change x axis value with even interval in scatter plot?)

如何在散點圖(地理地圖)上標註數據? (How to annotate data on the scatter plot (geo map)?)







留言討論