Hi,
Q 1)
I am entirely new to actual use of Streamlit. The functionality looks very promising to me.
Right now I am in the process of creating mockup in python. Yet looking into the various chart options ( Chart elements - Streamlit Docs), and following Streamlit, I do not seem to spot a visualisation rendering a network(x) infrastructure.
Is that because:
-
I am lacking imagination? …use e.g. plotly to display?
-
There is no option available?
Q 2)
I am a bit in doubt when using Streamlit. I did create my app.py file using the command prompt and things do seem to work, somehow. Still, trying to visualize (and maybe this points back to Q 1, above) I am not able to make the structures appear, e.g. using the below code (‘stolen’ from a tutorial elsewhere on the internet). Basically, this code ONLY provides plotly bars, representing the input provides by user, i.e. NO network structure comes from below code. It is merely intended for me to see, how I can make things happen with Streamlit (…and network(x)), In conclusion: Executing my app.py works fine, presenting charts doesn’t.
def nodes_and_edges():
a = int(input("Enter counter value 1: "))
b = int(input("Enter counter value 2: "))
c = int(input("Enter counter value 3: "))
test_a, test_b, test_c = , ,
# test_b =
# test_c =
i, j, k = 0, 0, 0
# j=0
# k=0
while i < a:
pl = int(input(“Enter item value 1:”))
test_a.append(pl)
i += 1
# print(list(test_a))
while j < b:
p2 = int(input("Enter item value 2: "))
test_b.append(p2)
j += 1
# print(list(test_b))
while k < c:
try:
p3 = int(input("Enter item value 3: "))
test_c.append(p3)
k += 1
except ValueError:
print(“Please input int only…”)
one = nodes_and_edges()
print("\none")
print(one)
user_input = tuple(one.itertuples(index=False, name=None))
interactions = user_input
G=nx.Graph(name=‘xxx Interaction Test Graph’)
interactions = np.array(interactions)
for i in range(len(interactions)):
interaction = interactions[i]
a = interaction[0] # source node
b = interaction[1] # destination node
w = float(interaction[2]) # score as weighted edge where high scores = low weight
G.add_weighted_edges_from([(a,b,w)]) # add weighted edge to graph
x1 = G.nodes(interactions[0])
x2 = G.nodes(interactions[1])
x3 = G.nodes(interactions[2])
Group data together
hist_data = [x1, x2, x3]
group_labels = [‘Value 1’, ‘value 2’, ‘Value 3’]
Create distplot with custom bin_size
fig = ff.create_distplot(hist_data, group_labels, bin_size=[.1, .25, .5])
Plot!
st.plotly_chart(fig, use_container_width=True)
Looking very much forward to learning your reply.
BR
Jens Steenfos, Copenhagen, Denmark
The Newbie