Unable to use subplots with mplfig

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Unable to use subplots with mplfig

Snehal Shekatkar
Hello all,

I am trying to use mplfig parameter of the graph_draw to draw 4 graphs on the same plot. My code is given below. However, this only produces graphs in first and second subplots. What am I missing?

import graph_tool.all as gt
import matplotlib.pyplot as plt
plt.switch_backend('cairo')

'''Load a graph'''
g = gt.collection.data['karate']

for ind in range(4):

    ax = plt.subplot(2, 2, ind+1)
    gt.graph_draw(g, mplfig = ax)

plt.savefig('karate4states.pdf')


Thank you

--
Snehal M. Shekatkar
Pune
India

_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unable to use subplots with mplfig

Snehal Shekatkar
Can somebody kindly help me with this? I am completely stuck.

Thank you


On Thu, Jul 27, 2017 at 2:12 PM, Snehal Shekatkar <[hidden email]> wrote:
Hello all,

I am trying to use mplfig parameter of the graph_draw to draw 4 graphs on the same plot. My code is given below. However, this only produces graphs in first and second subplots. What am I missing?

import graph_tool.all as gt
import matplotlib.pyplot as plt
plt.switch_backend('cairo')

'''Load a graph'''
g = gt.collection.data['karate']

for ind in range(4):

    ax = plt.subplot(2, 2, ind+1)
    gt.graph_draw(g, mplfig = ax)

plt.savefig('karate4states.pdf')


Thank you

--
Snehal M. Shekatkar
Pune
India



--
Snehal M. Shekatkar
Pune
India

_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unable to use subplots with mplfig

Alexandre Hannud Abdo
Funny thing, messing around with your example I find that graph_draw seems to be drawing onto the wrong axis: when you pass axis 3 it draws inside aixs 1, passing axis 4 draws inside axis 2, and what you pass as axes 1 and 2 is likely being drawn outside the canvas. Also, if you exapnd to 8 axes, it plots only 4 of them, so it seems things are being shifted halfway updards before drawing. I looked at the code but having never played with Cairo it is not evident what could be wrong, but hopefully this will help.

.~´


On Sat, Jul 29, 2017 at 6:25 AM, Snehal Shekatkar <[hidden email]> wrote:
Can somebody kindly help me with this? I am completely stuck.

Thank you


On Thu, Jul 27, 2017 at 2:12 PM, Snehal Shekatkar <[hidden email]> wrote:
Hello all,

I am trying to use mplfig parameter of the graph_draw to draw 4 graphs on the same plot. My code is given below. However, this only produces graphs in first and second subplots. What am I missing?

import graph_tool.all as gt
import matplotlib.pyplot as plt
plt.switch_backend('cairo')

'''Load a graph'''
g = gt.collection.data['karate']

for ind in range(4):

    ax = plt.subplot(2, 2, ind+1)
    gt.graph_draw(g, mplfig = ax)

plt.savefig('karate4states.pdf')


Thank you

--
Snehal M. Shekatkar
Pune
India



--
Snehal M. Shekatkar
Pune
India

_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool



_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unable to use subplots with mplfig

Snehal Shekatkar
Thanks for the reply. I don't think that there is any issue with graph tool. It simply looks like ignorance on my part because I have seen some figures in Tiago's papers which contain many network papers.

On Sat, Jul 29, 2017 at 8:36 PM, Alexandre Hannud Abdo <[hidden email]> wrote:
Funny thing, messing around with your example I find that graph_draw seems to be drawing onto the wrong axis: when you pass axis 3 it draws inside aixs 1, passing axis 4 draws inside axis 2, and what you pass as axes 1 and 2 is likely being drawn outside the canvas. Also, if you exapnd to 8 axes, it plots only 4 of them, so it seems things are being shifted halfway updards before drawing. I looked at the code but having never played with Cairo it is not evident what could be wrong, but hopefully this will help.

.~´


On Sat, Jul 29, 2017 at 6:25 AM, Snehal Shekatkar <[hidden email]> wrote:
Can somebody kindly help me with this? I am completely stuck.

Thank you


On Thu, Jul 27, 2017 at 2:12 PM, Snehal Shekatkar <[hidden email]> wrote:
Hello all,

I am trying to use mplfig parameter of the graph_draw to draw 4 graphs on the same plot. My code is given below. However, this only produces graphs in first and second subplots. What am I missing?

import graph_tool.all as gt
import matplotlib.pyplot as plt
plt.switch_backend('cairo')

'''Load a graph'''
g = gt.collection.data['karate']

for ind in range(4):

    ax = plt.subplot(2, 2, ind+1)
    gt.graph_draw(g, mplfig = ax)

plt.savefig('karate4states.pdf')


Thank you

--
Snehal M. Shekatkar
Pune
India



--
Snehal M. Shekatkar
Pune
India

_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool



_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool




--
Snehal M. Shekatkar
Pune
India

_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unable to use subplots with mplfig

Snehal Shekatkar
Dear Tiago,

Can you kindly suggest some solution on this?

Thank you


On Mon, Jul 31, 2017 at 8:11 PM, Snehal Shekatkar <[hidden email]> wrote:
Thanks for the reply. I don't think that there is any issue with graph tool. It simply looks like ignorance on my part because I have seen some figures in Tiago's papers which contain many network papers.

On Sat, Jul 29, 2017 at 8:36 PM, Alexandre Hannud Abdo <[hidden email]> wrote:
Funny thing, messing around with your example I find that graph_draw seems to be drawing onto the wrong axis: when you pass axis 3 it draws inside aixs 1, passing axis 4 draws inside axis 2, and what you pass as axes 1 and 2 is likely being drawn outside the canvas. Also, if you exapnd to 8 axes, it plots only 4 of them, so it seems things are being shifted halfway updards before drawing. I looked at the code but having never played with Cairo it is not evident what could be wrong, but hopefully this will help.

.~´


On Sat, Jul 29, 2017 at 6:25 AM, Snehal Shekatkar <[hidden email]> wrote:
Can somebody kindly help me with this? I am completely stuck.

Thank you


On Thu, Jul 27, 2017 at 2:12 PM, Snehal Shekatkar <[hidden email]> wrote:
Hello all,

I am trying to use mplfig parameter of the graph_draw to draw 4 graphs on the same plot. My code is given below. However, this only produces graphs in first and second subplots. What am I missing?

import graph_tool.all as gt
import matplotlib.pyplot as plt
plt.switch_backend('cairo')

'''Load a graph'''
g = gt.collection.data['karate']

for ind in range(4):

    ax = plt.subplot(2, 2, ind+1)
    gt.graph_draw(g, mplfig = ax)

plt.savefig('karate4states.pdf')


Thank you

--
Snehal M. Shekatkar
Pune
India



--
Snehal M. Shekatkar
Pune
India

_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool



_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool




--
Snehal M. Shekatkar
Pune
India



--
Snehal M. Shekatkar
Pune
India

_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unable to use subplots with mplfig

Tiago Peixoto
Administrator
On 02.08.2017 07:53, Snehal Shekatkar wrote:
> Can you kindly suggest some solution on this?

There seems to be a problem with the code, as Alexandre pointed out. I need
to take a closer look, but I'm out of time.

Please refrain from posting repeated messages like this. If I haven't
answered yet, is because I did not have a chance. Posting more messages does
not help.

Best,
Tiago

--
Tiago de Paula Peixoto <[hidden email]>


_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool

signature.asc (849 bytes) Download Attachment
--
Tiago de Paula Peixoto <tiago@skewed.de>
Loading...