如何为情节的主要部分赋予不同的颜色 [英] How to give different colors to parts of the main of a plot

查看:99
本文介绍了如何为情节的主要部分赋予不同的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只代表平均总成本,平均可变成本,平均固定成本和边际成本的曲线.

I simply represent the curves of Average Total Costs, Average Variable Costs, Average Fixed Costs and Marginal Costs.

plot(Q,ATCosts,ylab=NA,ylim=c(0,62),type="l")
par(new=T)
plot(Q,AVCosts,ylab=NA,ylim=c(0,62),type="l",col="blue")
par(new=T)
plot(Q,AFCosts,ylab=NA,ylim=c(0,62),type="l",col="red")
par(new=T)
plot(Q,MCosts,ylab=NA,ylim=c(0,62),type="l",col="green")

主要是:

title(main="ATC,AVC,AFC,MC")

我想知道的是,是否有一种方法可以给图中的每个主要部分(包含某种类型的成本)提供与该成本相关的颜色,从而避免使用图例.因此,ATC必须用黑色书写. AVC必须用蓝色写...等等.

What I would like to know is if there is a way to give each piece of the main (containing a certain type of cost) the color related to that cost in the plot, in order to avoid to use a legend. Thus, ATC must be written in black; AVC must be written in blue...and so on.

我尝试通过以下方式重叠另一个标题:

I tried to overlap another title in the following way:

title(main="   ,AVC,   ,  ",col.main="blue")

但是结果却不尽人意.

推荐答案

不是一般的解决方案,因为您必须使用adj来获得正确的间距,但是它可以起作用:

Not a general solution, because you have to play with the adj to get the right spacing, but it works:

plot(1)
mtext("ATC, ",col='black',line=2,adj=0.4)
mtext("AVC, ",col='blue',line=2,adj=0.45)
mtext("AFC, ",col='red',line=2,adj=0.5)
mtext("MC",col='green',line=2,adj=0.54)

这篇关于如何为情节的主要部分赋予不同的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆