Matlab:长,多行,传奇与乳胶口译员

时间:2017-04-22 11:10:51

标签: matlab-figure legend

我在图中有几行,每行都有自己的图例条目。其中一个图例条目很长,我需要将它分成几行。此外,由于我有一些符号出现,我需要使用乳胶解释器。

一切都很好,除非我似乎无法拆分长传奇条目。标准乳胶命令,如' \\',或' \ par'或' \ newline'似乎没有工作,只在输出中留下一个空格。

如果有人能帮助我,我将不胜感激。

由于

1 个答案:

答案 0 :(得分:0)

使用from random import randint from enum import Enum class Difficulty(Enum): easy = 'easy' hard = 'hard' class Pinball(object): def __init__(self, points = 0, balls = 3, winning_score = 20, hard_threshold = 5): self.winning_score = winning_score self.hard_threshold = hard_threshold self.difficulty = Difficulty.easy self.points = points self.balls = balls @property def points(self): return self._points @points.setter def points(self, v): self._points = v if v >= self.hard_threshold: self.difficulty = Difficulty.hard if v >= self.winning_score: self.win() @property def balls(self): return self._balls @balls.setter def balls(self, v): self._balls = v if v == 0: self.lose() def win(self): print('You win!') def lose(self): print('You lose!') # When you hit this bumper, you get random number from 1 3 def first_bumper(self): self.points += randint(1, 3) # when you hit this bumper, you get random number from 3 6 def second_bumper(self): self.points += randint(4, 6) # If you ball falls in hole, you lose one ball def losing_balls(self, count = 1): self.balls -= count # activate bumpers where you can lose points when # your points total reaches 5 def third_bumper(self, penalty = 1): if self.difficulty == Difficulty.hard: self.points -= penalty def fourth_bumper(self, penalty = 5): if self.difficulty == Difficulty.hard: self.points -= penalty sprintf

中嵌入“\n
legend()

legend(sprintf('%s\n%s', 'line', 'line')) 无效。