سؤال

في R، كيف يمكنني صنع ملصقات محور محور (بار) مؤامرة من المحور X بدلا من المحور Y؟

هل كانت مفيدة؟

المحلول

لست متأكدا مما إذا كان هذا هو ما تقصد، ولكن حاول الإعداد las=1. وبعد إليك مثال:

require(grDevices)
tN <- table(Ni <- stats::rpois(100, lambda=5))
r <- barplot(tN, col=rainbow(20), las=1)

output

هذا يمثل أسلوب ملصقات المحور. (0 = متوازي، 1 = كل الأفقي، 2 = كل عمودي على المحور، 3 = كل عمودي)

نصائح أخرى

يستخدم par(las=1).

يرى ?par:

las
numeric in {0,1,2,3}; the style of axis labels.
0: always parallel to the axis [default],
1: always horizontal,
2: always perpendicular to the axis,
3: always vertical.

كما Maciej Jończyk. المذكورة، قد تحتاج أيضا إلى زيادة الهوامش

par(las=2)
par(mar=c(8,8,1,1)) # adjust as needed
plot(...)

تحتاج إلى استخدام وظيفة الموضوع () كما يلي تسميات X-Axis الدورية بنسبة 60 درجة:

ggplot(...)+...+ theme(axis.text.x = element_text(angle=60, hjust=1))

أولا، قم بإنشاء بيانات المخطط

H <- c(1.964138757, 1.729143013,    1.713273714,    1.706771799,    1.67977205)
M <- c("SP105", "SP30", "SP244", "SP31",    "SP147")

ثانيا، امنح اسم ملف مخطط

png(file = "Bargraph.jpeg", width = 500, height = 300)

ثالثا، ارسم مخطط الشريط

barplot(H,names.arg=M,ylab="Degree ", col= rainbow(5), las=2, border = 0, cex.lab=1, cex.axis=1, font=1,col.axis="black")
title(xlab="Service Providers", line=4, cex.lab=1)

أخيرا، احفظ الملف

dev.off()

انتاج:

enter image description here

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top