我正在生成一个简单的图表:
data(iris); require(ggthemes)
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width)) +
geom_point(aes(shape=Species, colour=Petal.Width)) +
scale_colour_gradient() +
theme_gdocs() +
labs(shape="Species label", colour="Petal width label")
我想在这两个传说中划出一个共同的边界:
显然,代码theme(legend.background = element_rect(colour = 'black'))
将为每个图例元素生成两个边框。
答案 0 :(得分:2)
修改强>
从版本2.2.0开始,SpeechSynthesizer sSynth = new SpeechSynthesizer();
PromptBuilder pBuilder = new PromptBuilder();
SpeechRecognitionEngine sRecognize = new SpeechRecognitionEngine();
Choices sList = new Choices();
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
pBuilder.ClearContent();
pBuilder.AppendText(textBox2.Text);
sSynth.Speak(pBuilder);
}
private void button2_Click(object sender, EventArgs e)
{
button2.Enabled = false;
button3.Enabled = true;
sList.Add(new string[] { "who are you", "play a song" });
Grammar gr = new Grammar(new GrammarBuilder(sList));
try
{
sRecognize.RequestRecognizerUpdate();
sRecognize.LoadGrammar(gr);
sRecognize.SpeechRecognized += sRecognize_SpeechRecognized;
sRecognize.SetInputToDefaultAudioDevice();
sRecognize.RecognizeAsync(RecognizeMode.Multiple);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error");
}
}
private void sRecognize_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
textBox1.Text = textBox1.Text + " " + e.Result.Text.ToString() + "\r\n";
}
允许每个单独的图例(ggplot
)的边框,以及组合图例(legend.background
)的边框。将legend.box.background
设置为所需的颜色,填充,大小等。但也请将legend.box.background
设置为legend.background
。
element_blank()
您可能需要深入研究ggplot grob的结构;像这样的东西:
次要编辑:更新到ggplot2 2.0.0(和ggthemes 3.0.0)
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width)) +
geom_point(aes(shape=Species, colour=Petal.Width)) +
scale_colour_gradient() +
theme_gdocs() +
labs(shape="Species label", colour="Petal width label") +
theme(legend.background = element_blank(),
legend.box.background = element_rect(size = 2))