ggplot中的斜体希腊字母

时间:2019-10-15 01:31:35

标签: r ggplot2

现在变得非常挑剔,但是在ggplot2中有什么方法可以使刻面标题变为斜体?

我很容易得到希腊字母

import 'package:flutter/material.dart';
import 'package:quick_actions/quick_actions.dart';
import 'dart:io';

class QuickActionsManager extends StatefulWidget {
  final Widget child;
  QuickActionsManager({Key key, this.child}) : super(key: key);

  _QuickActionsManagerState createState() => _QuickActionsManagerState();
}

class _QuickActionsManagerState extends State<QuickActionsManager> {
  final QuickActions quickActions = QuickActions();

  @override
  void initState() {
    super.initState();
    _setupQuickActions();
    _handleQuickActions();
  }

  @override
  Widget build(BuildContext context) {
    return widget.child;
  }

  void _setupQuickActions() {
    quickActions.setShortcutItems(<ShortcutItem>[
      ShortcutItem(
          type: 'action_main',
          localizedTitle: 'Main view',
          icon: Platform.isAndroid ? 'quick_box' : 'QuickBox'),
      ShortcutItem(
          type: 'action_help',
          localizedTitle: 'Help',
          icon: Platform.isAndroid ? 'quick_heart' : 'QuickHeart')
    ]);
  }

  void _handleQuickActions() {
    quickActions.initialize((shortcutType) {
      if (shortcutType == 'action_main') {
        Navigator.push(
            context, MaterialPageRoute(builder: (context) => Login()));
      } else if(shortcutType == 'action_help') {
        print('Show the help dialog!');
      }
    });
  }

}

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'QuickActions Demo', home: QuickActionsManager(child: Home()));
  }
}

class Home extends StatelessWidget {
  const Home({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(body: Center(child: Text('Home')));
  }
}

class Login extends StatelessWidget {
  const Login({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(body: Center(child: Text('Login')));
  }
}

enter image description here

但是,如果我尝试使用斜体字

not supported

什么也没发生,它看起来与原始情节相同。

1 个答案:

答案 0 :(得分:1)

扩展@Ben Bolker注释,您可以对要斜体化/粗体显示的希腊字母使用Unicode字符来解决此问题。如果您可能希望通过italic()调用中的bold()expression()函数来做到这一点,这也将起作用。

对于您而言,将mu替换为\u03BC,并将sigma替换为\u03C3就足够了:

i3 <- iris %>% transform(Species = factor(ifelse(Species == "setosa", "italic(\u03BC)",
                                                 ifelse(Species == "versicolor", "bold(\u03C3)", "tau"))))

ggplot(i3, aes(Sepal.Width, Sepal.Length)) + 
    geom_point() + 
    facet_grid(.~Species, labeller = label_parsed)