当没有抗锯齿 ( samples=0) 时,此代码会呈现一个彩色三角形。但是当我打开抗锯齿 ( samples=1...32) 时,它无法渲染任何内容。如何使其与抗锯齿一起使用?也许我无法直接从多重采样 fbos 或纹理中读取像素,但我不知道如何解决这个问题。
import numpy as np
from PIL import Image
import moderngl
ctx = moderngl.create_standalone_context(backend='egl')
fbo = ctx.framebuffer(
color_attachments=ctx.texture((512, 512), 4, samples=2),
depth_attachment=ctx.depth_texture((512, 512), samples=2)
)
fbo.use()
vertices = np.array([
-1.0, -1.0, 1.0, 0.0, 0.0,
1.0, -1.0, 0.0, 1.0, 0.0,
0.0, 1.0, 0.0, 0.0, 1.0],
dtype='f4',
)
prog = ctx.program(vertex_shader="""
#version 330
in vec2 in_vert;
in vec3 in_color;
out vec3 color;
void main() {
gl_Position = vec4(in_vert, 0.0, 1.0);
color = …Run Code Online (Sandbox Code Playgroud) 我在 Windows 上安装了 Anaconda 3.7。它适用于 Jupyter,但不适用于 Spyder。这段代码:
import holoviews as hv
import pandas as pd
import numpy as np
output_notebook ()
flora = pd.read_csv ('iris.csv')
hv.extension('bokeh')
frequencies, edges = np.histogram(flora['petal width'], bins = 5)
print(frequencies, edges)
hv.Histogram(frequencies, edges, label = 'Histogram')
Run Code Online (Sandbox Code Playgroud)
只返回值:
[49 8 41 29 23] [0.1 0.58 1.06 1.54 2.02 2.5 ]
WARNING:root:Histogram: Histogram edges should be supplied as a tuple along with the values, passing the edges will be deprecated in holoviews 2.0.
Run Code Online (Sandbox Code Playgroud)
是否可以在 Spyder 中查看直方图?