To create a chart and set multiple positions:
import networkx as nx G=nx.Graph() G.add_edges_from([(1,2),(2,3),(3,1),(1,4)])

Your problem is that you calculate the positions of all nodes before setting the positions of fixed nodes.
Move pos = nx.spring_layout(G_pc,fixed=fixed_nodes) after setting pos[p] for fixed nodes and change it to pos = nx.spring_layout(G_pc,pos=pos,fixed=fixed_nodes)
dict pos stores the coordinates of each node. You should quickly look through the documentation . In particular,
pos : dict or None optional (default = None). Starting positions for nodes as a dictionary with node as keys and values โโas a list or tuple. If "No" then use random starting positions.
fixed : list or None optional (default = none). Nodes should be fixed in the starting position. list or None optional (default = None)
You say to keep these nodes in the starting position, but you did not tell them what this initial position should be. Therefore, I would believe that this is a random assumption for this initial position and fixes it. However, when I check this, it looks like I encountered an error. It seems that if I say (my version) networkx to keep the nodes in [1,2] as fixed, but I donโt talk about what their positions are, I get an error message (at the bottom of this answer). Therefore, I am surprised that your code is running.
For some other code enhancements using lists:
def get_coordinates_in_circle(n): thetas = [2*np.pi*(float(i)/n) for i in range(n)] returnlist = [(np.cos(theta),np.sin(theta)) for theta in thetas] return return_list G_pc = nx.Graph() G_pc.add_edges_from(edges_2212) circular_positions = get_coordinates_in_circle(len(dps_2211))
Here I see the error:
import networkx as nx G=nx.Graph() G.add_edge(1,2) pos = nx.spring_layout(G, fixed=[1,2]) --------------------------------------------------------------------------- UnboundLocalError Traceback (most recent call last) <ipython-input-4-e9586af20cc2> in <module>() ----> 1 pos = nx.spring_layout(G, fixed=[1,2]) .../networkx/drawing/layout.pyc in fruchterman_reingold_layout(G, dim, k, pos, fixed, iterations, weight, scale) 253 # We must adjust k by domain size for layouts that are not near 1x1 254 nnodes,_ = A.shape --> 255 k=dom_size/np.sqrt(nnodes) 256 pos=_fruchterman_reingold(A,dim,k,pos_arr,fixed,iterations) 257 if fixed is None: UnboundLocalError: local variable 'dom_size' referenced before assignment