Error in `ggsave()`: ! Dimensions exceed 50 inches (`height` and `width` are specified in inches not pixels). ℹ If you're sure you want a plot that big, use `limitsize = FALSE`. Run `rlang::last_trace()` to see where the error occurred.怎么修改
时间: 2023-07-28 08:07:04 浏览: 689
这个错误提示是因为你保存的图片的高度和宽度超过了50英寸,而ggsave函数默认的单位是英寸而不是像素。
如果你确定要保存这么大的图片,可以在ggsave函数中添加参数"limitsize = FALSE"来禁用尺寸限制。例如:
```
ggsave("plot.png", plot = myplot, width = 60, height = 40, limitsize = FALSE)
```
这将允许你保存60英寸宽,40英寸高的图片,但请注意这可能会导致一些显示问题,因为这样的图片可能太大了。
如果你不需要这么大的图片,可以调整width和height的值,使其小于50英寸。或者,你可以将height和width的单位修改为像素,例如:
```
ggsave("plot.png", plot = myplot, width = 3000, height = 2000, units = "px")
```
这将保存一个3000像素宽,2000像素高的图片,而不会有尺寸限制的错误。
相关问题
AC:All Accepted通过WA:Wrong Answer答案错误CE:Compilation Error编译错误TLE:Time Limit Exceed时间超限MLE:Memory Limit Exceed内存超限RE:Runtime Error运行时错误UKE:Unknown ERROR未知错误
你的第一个问题是关于程序运行时可能出现的错误类型,对吧?那么回答如下:
在程序运行的过程中,可能会出现各种错误。常见的错误类型包括:AC(All Accepted,表示程序通过了所有的测试用例)、WA(Wrong Answer,表示程序的输出结果错误)、CE(Compilation Error,表示程序编译出错)、TLE(Time Limit Exceed,表示程序运行时间超出了限制)、MLE(Memory Limit Exceed,表示程序使用的内存超出了限制)、RE(Runtime Error,表示程序在运行过程中发生了错误)以及UKE(Unknown Error,表示未知错误)。
The objective of the program you are going to produce is to evaluate boolean expressions as the one shown next: Expression: ( V | V ) & F & ( F | V ) where V is for True, and F is for False. The expressions may include the following operators: ! for not, & for and, | for or, the use of parenthesis for operations grouping is also allowed. To perform the evaluation of an expression, it will be considered the priority of the operators, the not having the highest, and the or the lowest. The program must yield V or F, as the result for each expression in the input file. Input The expressions are of a variable length, although will never exceed 100 symbols. Symbols may be separated by any number of spaces or no spaces at all, therefore, the total length of an expression, as a number of characters, is unknown. The number of expressions in the input file is variable and will never be greater than 20. Each expression is presented in a new line, as shown below. Output For each test expression, print "Expression " followed by its sequence number, ": ", and the resulting value of the corresponding test expression. Separate the output for consecutive test expressions with a new line. Use the same format as that shown in the sample output shown below. Sample Input ( V | V ) & F & ( F| V) !V | V & V & !F & (F | V ) & (!F | F | !V & V) (F&F|V|!V&!F&!(F|F&V)) Sample Output Expression 1: F Expression 2: V Expression 3: V
Here's a Python program that can solve the problem you described:
```python
# Define a helper function to calculate the value of a boolean expression
def evaluate(expression):
stack = []
for symbol in expression:
if symbol == '!':
operand = stack.pop()
stack.append(not operand)
elif symbol == '&':
right_operand = stack.pop()
left_operand = stack.pop()
stack.append(left_operand and right_operand)
elif symbol == '|':
right_operand = stack.pop()
left_operand = stack.pop()
stack.append(left_operand or right_operand)
elif symbol == 'V':
stack.append(True)
elif symbol == 'F':
stack.append(False)
return stack.pop()
# Read input expressions from a file
with open('input.txt', 'r') as input_file:
expressions = input_file.readlines()
# Evaluate each expression and print the result
for i, expression in enumerate(expressions):
expression = ''.join(expression.split()) # remove all whitespace
result = evaluate(expression)
print(f"Expression {i+1}: {'V' if result else 'F'}")
```
You can save the input expressions to a file named `input.txt`, and then run the program to get the output.
Note that the `evaluate()` function uses a stack to keep track of the operands and operators in the expression. It starts by iterating over each symbol in the expression, and for each symbol, it performs the corresponding operation. When it's done, the final result is left at the top of the stack, which is then returned by the function.
阅读全文