How to use the nxviz.base.BasePlot function in nxviz

To help you get started, we’ve selected a few nxviz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ericmjl / nxviz / nxviz / hive.py View on Github external
from .base import BasePlot
from .geometry import node_theta, get_cartesian
from collections import defaultdict
from matplotlib.path import Path

import matplotlib.patches as patches
import numpy as np
import matplotlib.pyplot as plt


class HivePlot(BasePlot):
    """
    Plotting object for HivePlot.
    """
    def __init__(self, nodes, edges,
                 nodecolors='blue', edgecolors='black',
                 nodeprops=dict(radius=0.2), edgeprops=dict(alpha=0.5),
                 figsize=(8, 8)):
        # Initialize using BasePlot
        BasePlot.__init__(self, nodes, edges)

        # The following method calls are specific to HivePlot.
        # 1. Set the .nodes attribute, but first do type checking.
        self.set_nodes(nodes)
        # 2. Set the major and minor angle attributes.
        self.set_major_angle()
        self.set_minor_angle()
github ericmjl / nxviz / nxviz / base.py View on Github external
def __init__(self, nodes, edges,
                 nodecolors='blue', edgecolors='black',
                 nodeprops=dict(radius=0.3), edgeprops=dict(alpha=0.5),
                 figsize=(8, 8)):
        super(BasePlot, self).__init__()
        self.nodes = nodes
        self.edges = edges

        # Set the node and edge props and colors.
        # These are written with functions because there are type checks that
        # have to take place first, and it would make the __init__ function
        # unwieldy to have them all in here.
        #
        # Later if we support other backends, such as Bokeh, it may be wise to
        # set these as "generic" parameters that we can write translators for
        # to other packages.
        self.set_nodeprops(nodeprops)
        self.set_edgeprops(edgeprops)
        self.set_nodecolors(nodecolors)
        self.set_edgecolors(edgecolors)
        # These functions end up setting the following object attributes:
github ericmjl / nxviz / nxviz / circos.py View on Github external
from .base import BasePlot
from .geometry import node_theta, get_cartesian
from matplotlib.path import Path

import matplotlib.patches as patches


class CircosPlot(BasePlot):
    """
    Plotting object for CircosPlot.
    """
    def __init__(self, nodes, edges, plot_radius,
                 nodecolors='blue', edgecolors='black',
                 nodeprops=dict(radius=0.3), edgeprops=dict(alpha=0.5),
                 figsize=(8, 8)):
        # Initialize using BasePlot
        BasePlot.__init__(self, nodes, edges)
        # The following attributes are specific to CircosPlot
        self.plot_radius = plot_radius
        # The rest of the relevant attributes are inherited from BasePlot.
        self.compute_node_positions()
        self.ax.set_xlim(-radius*1.2, radius*1.2)
        self.ax.set_ylim(-radius*1.2, radius*1.2)
        self.ax.xaxis.set_visible(False)