我正在尝试调整Octave中的一些情节.我已经能够改变线条粗细和轴标签.但是,我找不到一种方法来使轴本身更厚,或者数字更大.
我在网上找到的东西使用set(),比如
plot(x, y, "linewidth",5);
h=get(gcf, "currentaxes");
set(h, "fontsize", 12, "linewidth", 2);
Run Code Online (Sandbox Code Playgroud)
要么
set(gca, 'linewidth', 4);
Run Code Online (Sandbox Code Playgroud)
但是,我继续看到错误
invalid property 'linewidth'
invalid property 'fontsize'
Run Code Online (Sandbox Code Playgroud)
即使它们在Octave文档中列为属性
我究竟做错了什么?
或者,我还能尝试什么?
假设我Person在Julia中指定了一个类型:
type Person
name::String
male::Bool
age::Float64
children::Int
end
function describe(p::Person)
println("Name: ", p.name, " Male: ", p.male)
println("Age: ", p.age, " Children: ", p.children)
end
ted = Person("Ted",1,55,0)
describe(ted)
Run Code Online (Sandbox Code Playgroud)
哪个将输出功能:
Name: Ted Male: true
Age: 55.0 Children: 0
Run Code Online (Sandbox Code Playgroud)
然后我修改了类型的功能,我在该类型Person中添加了一个新类别eyes
type Person
name::String
male::Bool
age::Float64
children::Int
eyes::String
end
ted = Person("Ted",1,55,0,brown)
Run Code Online (Sandbox Code Playgroud)
如果我现在运行该功能,我会收到错误
Error evaluating REPL:
invalid redefinition of constant Person
in include_string at loading.jl:97
Run Code Online (Sandbox Code Playgroud)
在开发新代码时,解决此问题的最佳方法是什么?除了按照朱莉娅常见问题解答中的建议制作模块
MATLAB(文档):
>> double('?')
ans =
945
Run Code Online (Sandbox Code Playgroud)
Octave 4.0.0,Ubuntu 16.04(文档):
>> double('?')
ans =
206 177
Run Code Online (Sandbox Code Playgroud)
为什么我会得到不同的结果?
注意:'α'是希腊小写字母alpha.
我QGraphicsScene在 PyQT 中进行子类化,并希望使用Shift键(修饰符)来代替键来进行多选项目control。
我可以通过子类化它并制作自己的 来做到这一点mousePressedEvent,但是当我这样做时,当我开始拖动场景中的graphicsItem时,它们会表现得很奇怪。
我需要的只是将control键更改shift为多选键。如果有人可以提供帮助,我将不胜感激。
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class GraphicsScene(QGraphicsScene):
def __init__(self, parent=None, ns=""):
super(GraphicsScene, self).__init__(parent)
self.parent = parent
self.prevItem = []
self.ns = ns
self.setBackgroundBrush(QBrush(QColor(50,50,50) , Qt.SolidPattern))
def mouseReleaseEvent(self, event):
if event.button() == 2: #Right mouse click
#Set previous selections selected
for item in self.prevItem:
item.setSelected(1)
item = self.itemAt(event.lastScenePos ().x(), event.lastScenePos ().y())
if item:
item.setSelected(1)
if event.button() == 1: # Left …Run Code Online (Sandbox Code Playgroud) 我正在用八度音绘制轮廓,并使用命令saveas(gcf,'rainzam.pdf')我得到输出正常,但我只是想知道为什么我得到以下警告:
warning: print.m: epstool binary is not available.
Some output formats are not available.
warning: print.m: fig2dev binary is not available.
Some output formats are not available.
Run Code Online (Sandbox Code Playgroud)
这并不严重,但如果有办法让它们消失,我将不胜感激.
例如,如果函数的输出(例如indexin)具有Vector{Union{Nothing, Int64}}类型,
但事先知道只会输出值(没有nothing)。
并且这个输出应该被馈送到另一个
对于这种类型有问题的函数,但是对于一个简单的Int64.
说
julia> output = Union{Nothing, Int64}[1, 2] # in practice, that would be output from a function
2-element Vector{Union{Nothing, Int64}}:
1
2
Run Code Online (Sandbox Code Playgroud)
如何将该输出转换为数组Int64?
以下在这种情况下有效,并且可以收集在一个函数中,但必须有一种更优雅的方式。
julia> subtypes = Base.uniontypes(eltype(output))
2-element Vector{Any}:
Nothing
Int64
julia> no_Nothing = filter(!=(Nothing), subtypes)
1-element Vector{Any}:
Int64
julia> new_eltype = Union{no_Nothing...}
Int64
julia> Array{new_eltype}(output)
2-element Vector{Int64}:
1
2
Run Code Online (Sandbox Code Playgroud)