graph

How to give diferent colors to diferent lines in matplotlib

How to give diferent colors to diferent lines in matplotlib Question: materias = ["MAT 1","MAT 2","MAT 3","FIS 1","FIS 2","FIS 3","QUI 1","QUI 2","GEO 1","GEO 2","PORT","RED","LIT","ART","ING","HIST 1","HIST 2","FIL","SOC","EDF","BIO 1","BIO 2","BIO 3" ] for i in materias: note= str(i) file_name = ‘images/’ + str(i) +’.png’ print(i,":") plt.plot(df["PROVAS"], df[i], label=note) plt.legend() plt.savefig(file_name) plt.show() i dont know how to merge …

Total answers: 1

How to transform a list of lists in Python into a dictionary

How to transform a list of lists in Python into a dictionary Question: I have in Python an structure like this one example = { [‘g’: ‘h’], [ {‘a’:’b’}, {‘c’: ‘d’}, {‘a’:’b’}, {‘e’, ‘f’} ] } I want to create a dictionary that represents the information of this list considering it a graph in the …

Total answers: 1

Finding the root nodes in a networkx.Graph() and paths between those nodes

Finding the root nodes in a networkx.Graph() and paths between those nodes Question: This should be a simple question, but one I am not sure how to answer since I am new to the networkx api. The graphs I will be working with will not be directed and be acyclic. I have created a nx.Graph(), …

Total answers: 1

Printing binary tree after initialising gives None value

Printing binary tree after initialising gives None value Question: I have a simple binary tree. I have intialized it using TreeNode class, but while printing out the values from the tree, it gives me None value as well. How to mitigate this? The code snippet is as follows: class TreeNode: def __init__(self, root=None, left = …

Total answers: 2

Drawing a directed graph from a list of nodes with Python

Drawing a directed graph from a list of nodes with Python Question: That’s the ending graph that I would like to end up with, but to begin with it would be great to have simply bus late and overslept without considering the alarm on node. I would like to know how to draw a directed …

Total answers: 2

Remove all nodes that has a particular attribute in networkx

Remove all nodes that has a particular attribute in networkx Question: I`m trying to remove all nodes within a Graph that has an specific attribute value. I have seen this: python networkx remove nodes and edges with some condition But in that case the degree is a property and not an attribute. My graph has …

Total answers: 1

Minimum cost to set internet in all rooms?

Minimum cost to set internet in all rooms? Question: There are n rooms in a hostel. We want to supply internet to all the rooms, laying a proper network. For each room ‘i’, we can either have a router directly with the cost ‘router[i]’, or connect that room through an ethernet cable pulled from another …

Total answers: 2

Multiple boxplots on the same graph

Multiple boxplots on the same graph Question: I need to create multiple boxplots on the same graph. The sports are 3. I need to obtain 3 boxplots on the same graph of each sport, with a specific variable on the y-axis. I need to be able to change the variable. The variable for each student …

Total answers: 1

AttributeError: module 'networkx' has no attribute 'from_numpy_matrix'

AttributeError: module 'networkx' has no attribute 'from_numpy_matrix' Question: A is co occurrence dataframe. Why it shown AttributeError: module ‘networkx’ has no attribute ‘from_numpy_matrix’ import numpy as np import networkx as nx import matplotlib A=np.matrix(coocc) G=nx.from_numpy_matrix(A) Asked By: Pranab || Source Answers: In networkx 3.0 the changelog shows the following "Remove to_numpy_matrix & from_numpy_matrix (#5746)" https://networkx.org/documentation/stable/release/release_3.0.html …

Total answers: 2

How to plot labels in alphabetical orders with coulour-gradient in python?

How to plot labels in alphabetical orders with coulour-gradient in python? Question: I want to plot labels "nutrition_grade_fr" in alphabetical orders with coulour-gradient in python. Here is the code for my graph but it does not show the labels in alphabetical order nor with the corresponding hue: import seaborn as sns import matplotlib.pyplot as plt …

Total answers: 1