如何让R中lattice包的多面板Dotplot所有面板显示X轴值?
Solution for Showing X-Axis Labels on All Lattice Dotplot Panels
To display X-axis labels on every panel of your Dotplot while preserving Y-axis factor labels, adjust the scales parameter to target only the x-axis's alternating behavior. Avoid using the global alternating=FALSE argument, as it affects both axes and causes Y-axis labels to revert to numeric values.
Corrected Code
library(lattice) Dotplot(percentile~Cbind(pm10,llim,ulim)|lag, data=df3, xlab="PM 10", scales=list(x=list(alternating=FALSE)))
Explanation
- The
scales=list(x=list(alternating=FALSE))setting forces every panel to render X-axis ticks and labels. - The Y-axis retains its original factor labels because we didn't modify the Y-axis's alternating behavior (default is
alternating=1, which shows labels only on leftmost panels).
If you also want Y-axis labels on all panels, extend the scales argument:
scales=list(x=list(alternating=FALSE), y=list(alternating=FALSE))
内容的提问来源于stack exchange,提问作者Ridhima
相关产品推荐
相关产品推荐

