小编pce*_*con的帖子

文本被剪切的情节 - Matplotlib/Python

我正在使用以下代码绘制一个简单的箱形图,但是从结果中可以看出,某些单词被剪切掉了.我怎么解决这个问题?

def generate_data_boxplots(data, ticks, x_axis_label, y_axis_label, file_path):
    """
    Plot multiple data boxplots in parallel
    :param data : a set of data to be plotted
    :param x_axis_label : the x axis label of the data
    :param y_axis_label : the y axis label of the data
    :param file_path : the path where the output will be save
    """
    plt.figure()
    bp = plt.boxplot(data, sym='r+')
    plt.xticks(numpy.arange(1, len(ticks)+1), ticks, rotation=15)
    plt.xlabel(x_axis_label)
    plt.ylabel(y_axis_label)

    # Overplot the sample averages, with horizontal alignment in the center of each …
Run Code Online (Sandbox Code Playgroud)

python matplotlib

4
推荐指数
1
解决办法
2813
查看次数

获取箱线图的数据 - Matplotlib

我必须绘制一些数据的箱线图,我可以使用Matplotlib轻松完成。但是,我被要求提供一个表格,其中包含其中显示的数据,例如须线、中位数、标准差等。

\n\n

我知道我可以“手动”计算这些,但我也从参考文献中知道该boxplot方法:

\n\n
Returns a dictionary mapping each component of the boxplot to a list of the matplotlib.lines.Line2D instances created. That dictionary has the following keys (assuming vertical boxplots):\n\nboxes: the main body of the boxplot showing the quartiles and the median\xe2\x80\x99s confidence intervals if enabled.\nmedians: horizonal lines at the median of each box.\nwhiskers: the vertical lines extending to the most extreme, n-outlier data points.\ncaps: the horizontal lines at the ends of the whiskers.\nfliers: points representing …
Run Code Online (Sandbox Code Playgroud)

python matplotlib boxplot

4
推荐指数
1
解决办法
2万
查看次数

当字典 - python中显示时,浮动打印的方式不同

我正在用这个简单的代码创建一个字典:

pixel_histogram = {}
min_value = -0.2
max_value = 0.2
interval_size = (math.fabs(min_value) + math.fabs(max_value))/bins

for i in range(bins):
    key = min_value+(i*interval_size)
    print key
    pixel_histogram[key] = 0
    print pixel_histogram
Run Code Online (Sandbox Code Playgroud)

但我有点惊讶,因为我的印刷品得到了这些值:

#Printing keys
-0.2
-0.16
-0.12
-0.08
-0.04
0.0
0.04
0.08
0.12
0.16

#Printing the dictionary
{0.0: 0, 
-0.08000000000000002: 0, 
0.15999999999999998: 0, 
-0.16: 0, 
0.12: 0, 
-0.12000000000000001: 0, 
0.08000000000000002: 0, 
-0.04000000000000001: 0, 
-0.2: 0, 
0.03999999999999998: 0}
Run Code Online (Sandbox Code Playgroud)

我没弄清楚为什么值不同,我怎么能解决这个问题.任何帮助,将不胜感激.谢谢.

python dictionary numbers key

3
推荐指数
1
解决办法
802
查看次数

使用不同的步骤创建numpy数组

我想创建一个如下所示的数组:

# 0 | 4 | 8 | 16 | 32
Run Code Online (Sandbox Code Playgroud)

其中,除第一个之外的每个元素是前一个元素的两倍.我可以通过迭代创建这个更小的东西,依此类推.

但是,由于Python提供了许多单线函数,我想知道是否有一个允许我这样做.

python arrays numpy sequence

3
推荐指数
1
解决办法
1159
查看次数

在OpenGL中找不到属性变量,可能的优化

我目前正在使用延迟着色,我创建了一个管理FBO并在屏幕上绘制缓冲区的类.

这是它到目前为止的样子:

FBORender::FBORender(float screenWidth, float screenHeight) :
    _screenWidth(screenWidth),
    _screenHeight(screenHeight),
    ProgramManager("defVertexShader.txt", "defFragShader.txt")
{
    CreateProgram();
    _vbo[0] = 0;
    _vbo[1] = 0;
    _vao = 0;
    BuildQuad();
    BuildVAO();


    glGenFramebuffers(1, &_fbo);
    glGenRenderbuffers(1, &_depthBuffer);

    // Bind the depth buffer
    glBindRenderbuffer(GL_RENDERBUFFER, _depthBuffer);
    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, (int)_screenWidth, (int)_screenHeight);

    // Generate and bind the texture for diffuse
    glGenTextures(1, &_diffuseBuffer);
    glBindTexture(GL_TEXTURE_2D, _diffuseBuffer);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (int)_screenWidth, (int)_screenWidth, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

    // Generate and bind the texture for positions …
Run Code Online (Sandbox Code Playgroud)

opengl optimization shader glsl

3
推荐指数
1
解决办法
50
查看次数

使用引导程序设置全屏leaflet.js映射

我正在根据以下示例创建模板:

http://getbootstrap.com/examples/dashboard/

http://leafletjs.com/examples/choropleth.html

我只想要一张完整的传单地图。但是,我无法使其正常工作。

这是我的index.html文件:

<!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="utf-8">
            <title>NY Noise Map</title>
            <script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
            <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> 
            <!-- ####Leaflet#### -->
            <script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
            <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
            <!-- ################ -->
            <!-- ####Bootstrap### -->
            <script src="bootstrap-3.3.6-dist/js/bootstrap.min.js"></script>
            <link rel="stylesheet" href="bootstrap-3.3.6-dist/css/bootstrap.min.css" />
            <!-- ################ -->
            <!-- #####Custom##### -->
            <script src="Scripts/map.js"></script>
            <link rel="stylesheet" href="CSS/dashboard.css" />
            <!-- ################ -->
        </head>
        <body>
            <!-- Top bar -->
            <nav class="navbar navbar-inverse navbar-fixed-top">
                <div class="container-fluid">
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> …
Run Code Online (Sandbox Code Playgroud)

javascript css twitter-bootstrap leaflet

3
推荐指数
1
解决办法
7399
查看次数

如何在seaborn中检索错误栏

我使用以下函数在seaborn中绘制了条形图:

ax = sns.barplot(x='Year', y='Value', data=df)
Run Code Online (Sandbox Code Playgroud)

现在我想根据以下规则为每个条形着色:

percentages = []
for bar, yerr_ in zip(bars, yerr):
    low  = bar.get_height() - yerr_
    high = bar.get_height() + yerr_
    percentage = (high-threshold)/(high-low)
    if percentage>1: percentage = 1
    if percentage<0: percentage = 0
    percentages.append(percentage)
Run Code Online (Sandbox Code Playgroud)

我相信我可以通过 ax.patches 访问这些条,它返回一组矩形:

for p in ax.patches:
    height = p.get_height()
    print(p)
>> Rectangle(-0.4,0;0.8x33312.1)
>> Rectangle(0.6,0;0.8x41861.9)
>> Rectangle(1.6,0;0.8x39493.3)
>> Rectangle(2.6,0;0.8x47743.6)
Run Code Online (Sandbox Code Playgroud)

但是,我不知道如何检索由seaborn/matplotlib计算的yerr数据。

python matplotlib seaborn

3
推荐指数
1
解决办法
1021
查看次数

使用Matplotlib/Python绘制模糊的线条

我想知道是否有可能使用Matplotlib进行下面的可视化.

在此输入图像描述

另一种观点:

在此输入图像描述

资料来源:http://dl.acm.org/citation.cfm?id = 1961832

这些图像做了哪些以及我想要做的是组合两个可视化.一个(背景)是一个简单的情节,可以用imshow,pcolor,pcolormesh完成,但另一个使用网格纹理,模糊(w因子)决定了一些特征,在这种情况下,不确定性.我不知道该怎么做是用不同的模糊绘制不同的线条.对于每个像素,我有一个不确定性,我应该在这个像素中画一条线,不确定性表示为线条模糊.

我不知道如何用Matplotlib做后者(用模糊绘制线条).

任何帮助,将不胜感激.先感谢您.

python textures glyph matplotlib

0
推荐指数
1
解决办法
757
查看次数