简体   繁体   English

Matplotlib在缩放时绘制错误的分辨率

[英]Matplotlib plot bad resolution when zooming

I am using matplotlib to plot hierarchical clusterings, 我使用matplotlib绘制层次聚类,

import numpy as np

from scipy.cluster.hierarchy import dendrogram

def plot_dendrogram(model, **kwargs):

    # Children of hierarchical clustering
    children = model.children_

    # Distances between each pair of children
    # Since we don't have this information, we can use a uniform one for plotting
    distance = np.arange(children.shape[0])



    # The number of observations contained in each cluster level
    no_of_observations = np.arange(2, children.shape[0]+2)

    # Create linkage matrix and then plot the dendrogram
    linkage_matrix = np.column_stack([children, distance, no_of_observations]).astype(float)

    # Plot the corresponding dendrogram
    dendrogram(linkage_matrix, **kwargs)

plt.figure(figsize=(100,100))
plt.title('Hierarchical Clustering Dendrogram')
plot_dendrogram(clustering, labels=liste_tags)
plt.show()

I can visualize the hierarchical clustering, however the quality and resolution of the plot is not good. 我可以想象层次聚类,但是图的质量和分辨率并不好。 Especially, when I save the plot and try to zoom in to see the labels for example. 特别是,当我保存绘图并尝试放大以查看标签时。

I get this image : 我得到这个图像: 在此输入图像描述

MatPlotLib Figure object has a dpi parameter. MatPlotLib图对象有一个dpi参数。 Just set something like plt.figure(figsize=(100,100), dpi=300) . 只需设置像plt.figure(figsize=(100,100), dpi=300)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM