سؤال

استخدام mtext لوصف التسمية يفعل شيئًا مختلفًا عن استخدام xlab.كيف يمكنني جعل تسميات mtext دائمًا بنفس الحجم الذي ستكون عليه عند استخدام xlab (دون تحديد وسيطة cex دائمًا).في المثال البسيط أدناه cex=cex.lab=1 لكلا الشكلين.لكن الحجم مختلف.

layout(matrix(c(1,1,2,2), ncol=1))
op<-par(mar=c(4,4,2,1))
plot(1:10, xlab="", ylab="", main="This is my title")
mtext("this is the x-axis", side=1, line=2.75, cex=1)
mtext("this is the y-axis", side=2, line=2.5, cex=1)
plot(1:10,  xlab="this is smaller", ylab="this is smaller", main="This is my title", cex.lab=1)
par(op)

enter image description here

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

المحلول

عندما يتم استخدام التخطيط، فإن معنى cex=1 في plot مختلف، لكنني لم أكن أتوقع أن يمتد هذا الاختلاف إلى mtext نظرًا لأن أنشطته تقع خارج مناطق التخطيط الفردية.يمكنك عكس التخفيض الافتراضي في "فعال"-cex داخل plot عن طريق عكس العامل المتوقع 2/3:

layout(matrix(c(1,1,2,2), ncol=1))
op<-par(mar=c(4,4,2,1))
plot(1:10, xlab="", ylab="", main="This is my title")
mtext("this is the x-axis", side=1, line=2.75, cex=1)
mtext("this is the y-axis", side=2, line=2.5, cex=1)
plot(1:10,  xlab="this is _not_ smaller", 
            ylab="this is _not_ smaller, either", 
            main="This is my title", 
            cex.lab=3/2)
par(op)

قراءة متعمقة:

 ?par  # scroll down to mfcol, mfrow
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top