Discussion:
[Matplotlib-users] plt scale x-axis by constant factor f
Christian Jorgensen
2015-03-09 17:38:37 UTC
Permalink
How can I scale my x-axis [0,3000] for the data to now correspond/show up
as [0, 300]?


In xmgrace, this is done with a linear transformation, but I cannot seem
to find the command to do this with matplotlib.

Best
Sterling Smith
2015-03-09 17:51:59 UTC
Permalink
Christian,

It sounds like you want to rescale your x axis values before plotting or use the x axis formatter. For the latter see
http://matplotlib.org/examples/pylab_examples/major_minor_demo1.html
http://matplotlib.org/examples/pylab_examples/custom_ticker1.html

-Sterling
Post by Christian Jorgensen
How can I scale my x-axis [0,3000] for the data to now correspond/show up
as [0, 300]?
In xmgrace, this is done with a linear transformation, but I cannot seem
to find the command to do this with matplotlib.
Best
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Benjamin Root
2015-03-09 17:52:20 UTC
Permalink
Ok, this really should be simple (and I am sure it is), but I cannot, for
the life of me, find the appropriate documentation for it. We need better
documentation about how to utilize the offset-text feature of tickers. It
can be either a multiple offset or an additive offset.

In any case, I know there is a better way to do this, but here is a
quick-n-dirty example that can get you where you want. Just modify the
formatter used by the tickers to report the value as divided by 10.
http://matplotlib.org/examples/pylab_examples/custom_ticker1.html

Cheers!
Ben Root
Post by Christian Jorgensen
How can I scale my x-axis [0,3000] for the data to now correspond/show up
as [0, 300]?
In xmgrace, this is done with a linear transformation, but I cannot seem
to find the command to do this with matplotlib.
Best
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for
all
things parallel software development, from weekly thought leadership blogs
to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Christian Jorgensen
2015-03-09 17:57:56 UTC
Permalink
My array does not have an explicit x-coordinate
representation. The x-coordinate is simply the index.
print(array)
[ 0 0 20 ..., 8 8 8]
Thus what I would like is to adjoin the element
index as another row, how is this possible?
I cannot format x because it is not explicitly defined.
Post by Benjamin Root
Ok, this really should be simple (and I am sure it is), but I cannot, for
the life of me, find the appropriate documentation for it. We need better
documentation about how to utilize the offset-text feature of tickers. It
can be either a multiple offset or an additive offset.
In any case, I know there is a better way to do this, but here is a
quick-n-dirty example that can get you where you want. Just modify the
formatter used by the tickers to report the value as divided by 10.
http://matplotlib.org/examples/pylab_examples/custom_ticker1.html
Cheers!
Ben Root
Post by Christian Jorgensen
How can I scale my x-axis [0,3000] for the data to now correspond/show up
as [0, 300]?
In xmgrace, this is done with a linear transformation, but I cannot seem
to find the command to do this with matplotlib.
Best
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your hub
for all
things parallel software development, from weekly thought leadership
blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
_______
Christian JÞrgensen
--
_______

Christian JÞrgensen
Benjamin Root
2015-03-09 18:03:29 UTC
Permalink
I am not sure I understand. I took your question as "how do I make my x
tick labels show values as [0, 300] when my values really are [0, 3000]?".
Are the indexes you speak of ranging from 0 to 3000? If so, I don't see how
our examples aren't sufficient. As for formatting x "because it is not
defined", what is not defined? The formatting or x?
My array does not have an explicit x-coordinate
representation. The x-coordinate is simply the index.
print(array)
[ 0 0 20 ..., 8 8 8]
Thus what I would like is to adjoin the element
index as another row, how is this possible?
I cannot format x because it is not explicitly defined.
Post by Benjamin Root
Ok, this really should be simple (and I am sure it is), but I cannot,
for the life of me, find the appropriate documentation for it. We need
better documentation about how to utilize the offset-text feature of
tickers. It can be either a multiple offset or an additive offset.
In any case, I know there is a better way to do this, but here is a
quick-n-dirty example that can get you where you want. Just modify the
formatter used by the tickers to report the value as divided by 10.
http://matplotlib.org/examples/pylab_examples/custom_ticker1.html
Cheers!
Ben Root
Post by Christian Jorgensen
How can I scale my x-axis [0,3000] for the data to now correspond/show up
as [0, 300]?
In xmgrace, this is done with a linear transformation, but I cannot seem
to find the command to do this with matplotlib.
Best
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your hub
for all
things parallel software development, from weekly thought leadership
blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
_______
Christian JÞrgensen
--
_______
Christian JÞrgensen
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for
all
things parallel software development, from weekly thought leadership blogs
to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Christian Jorgensen
2015-03-09 18:12:18 UTC
Permalink
My array is called D.dtrajs[0]

I'm plotting it as

plt.plot(D.dtrajs[0])
plt.ylabel('O2-Fe distance')
plt.xlabel('Frame')


There is thus no x-variable defined to
scale or modify. How would you do this?
Post by Christian Jorgensen
Post by Benjamin Root
I am not sure I understand. I took your question as "how do I make my x
tick labels show values as [0, 300] when my values really are [0, 3000]?".
Are the indexes you speak of ranging from 0 to 3000? If so, I don't see how
our examples aren't sufficient. As for formatting x "because it is not
defined", what is not defined? The formatting or x?
My array does not have an explicit x-coordinate
representation. The x-coordinate is simply the index.
print(array)
[ 0 0 20 ..., 8 8 8]
Thus what I would like is to adjoin the element
index as another row, how is this possible?
I cannot format x because it is not explicitly defined.
Post by Benjamin Root
Ok, this really should be simple (and I am sure it is), but I cannot,
for the life of me, find the appropriate documentation for it. We need
better documentation about how to utilize the offset-text feature of
tickers. It can be either a multiple offset or an additive offset.
In any case, I know there is a better way to do this, but here is a
quick-n-dirty example that can get you where you want. Just modify the
formatter used by the tickers to report the value as divided by 10.
http://matplotlib.org/examples/pylab_examples/custom_ticker1.html
Cheers!
Ben Root
On Mon, Mar 9, 2015 at 1:38 PM, Christian Jorgensen <
Post by Christian Jorgensen
How can I scale my x-axis [0,3000] for the data to now
correspond/show up
as [0, 300]?
In xmgrace, this is done with a linear transformation, but I cannot seem
to find the command to do this with matplotlib.
Best
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your
hub for all
things parallel software development, from weekly thought leadership
blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
_______
Christian JÞrgensen
--
_______
Christian JÞrgensen
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your hub
for all
things parallel software development, from weekly thought leadership
blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
_______
Christian JÞrgensen
--
_______

Christian JÞrgensen
Sterling Smith
2015-03-09 18:11:43 UTC
Permalink
Christian,

To define your x coordinate, try
x = range(len(array))
x = x/10.
plot(x,array)

-Sterling
My array does not have an explicit x-coordinate
representation. The x-coordinate is simply the index.
print(array)
[ 0 0 20 ..., 8 8 8]
Thus what I would like is to adjoin the element
index as another row, how is this possible?
I cannot format x because it is not explicitly defined.
Ok, this really should be simple (and I am sure it is), but I cannot, for the life of me, find the appropriate documentation for it. We need better documentation about how to utilize the offset-text feature of tickers. It can be either a multiple offset or an additive offset.
In any case, I know there is a better way to do this, but here is a quick-n-dirty example that can get you where you want. Just modify the formatter used by the tickers to report the value as divided by 10.
http://matplotlib.org/examples/pylab_examples/custom_ticker1.html
Cheers!
Ben Root
How can I scale my x-axis [0,3000] for the data to now correspond/show up
as [0, 300]?
In xmgrace, this is done with a linear transformation, but I cannot seem
to find the command to do this with matplotlib.
Best
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
_______
Christian Jørgensen
--
_______
Christian Jørgensen
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Sterling Smith
2015-03-09 18:13:16 UTC
Permalink
That was untested. It should start with (still untested)

x = array(range(len(array))
Post by Sterling Smith
Christian,
To define your x coordinate, try
x = range(len(array))
x = x/10.
plot(x,array)
-Sterling
My array does not have an explicit x-coordinate
representation. The x-coordinate is simply the index.
print(array)
[ 0 0 20 ..., 8 8 8]
Thus what I would like is to adjoin the element
index as another row, how is this possible?
I cannot format x because it is not explicitly defined.
Ok, this really should be simple (and I am sure it is), but I cannot, for the life of me, find the appropriate documentation for it. We need better documentation about how to utilize the offset-text feature of tickers. It can be either a multiple offset or an additive offset.
In any case, I know there is a better way to do this, but here is a quick-n-dirty example that can get you where you want. Just modify the formatter used by the tickers to report the value as divided by 10.
http://matplotlib.org/examples/pylab_examples/custom_ticker1.html
Cheers!
Ben Root
How can I scale my x-axis [0,3000] for the data to now correspond/show up
as [0, 300]?
In xmgrace, this is done with a linear transformation, but I cannot seem
to find the command to do this with matplotlib.
Best
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
_______
Christian Jørgensen
--
_______
Christian Jørgensen
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Benjamin Root
2015-03-09 18:16:20 UTC
Permalink
Or just do this:

formatter = FuncFormatter(lambda x, pos: "%d" % x/10)
fig, ax = plt.subplots()ax.yaxis.set_major_formatter(formatter)plt.plot(D.dtrajs[0])
plt.ylabel('O2-Fe distance')
plt.xlabel('Frame')
plt.show()
Post by Sterling Smith
Christian,
To define your x coordinate, try
x = range(len(array))
x = x/10.
plot(x,array)
-Sterling
My array does not have an explicit x-coordinate
representation. The x-coordinate is simply the index.
print(array)
[ 0 0 20 ..., 8 8 8]
Thus what I would like is to adjoin the element
index as another row, how is this possible?
I cannot format x because it is not explicitly defined.
Ok, this really should be simple (and I am sure it is), but I cannot,
for the life of me, find the appropriate documentation for it. We need
better documentation about how to utilize the offset-text feature of
tickers. It can be either a multiple offset or an additive offset.
In any case, I know there is a better way to do this, but here is a
quick-n-dirty example that can get you where you want. Just modify the
formatter used by the tickers to report the value as divided by 10.
http://matplotlib.org/examples/pylab_examples/custom_ticker1.html
Cheers!
Ben Root
How can I scale my x-axis [0,3000] for the data to now correspond/show up
as [0, 300]?
In xmgrace, this is done with a linear transformation, but I cannot seem
to find the command to do this with matplotlib.
Best
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your hub
for all
things parallel software development, from weekly thought leadership
blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
_______
Christian JÞrgensen
--
_______
Christian JÞrgensen
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your hub
for all
things parallel software development, from weekly thought leadership
blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now.
http://goparallel.sourceforge.net/_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Christian Jorgensen
2015-03-09 18:35:00 UTC
Permalink
Thanks,


I ran Benjamin's code but it doesn't display the
figure anymore. It only prints a text about the figure


formatter = FuncFormatter(lambda x, pos: "%d" % x/10)



fig, ax = plt.subplots()

ax.yaxis.set_major_formatter(formatter)

plt.plot(D.dtrajs[0])

plt.ylabel('O2-Fe distance')

plt.xlabel('Frame')

plt.show()

<matplotlib.figure.Figure at 0x11b1f2090>
Post by Benjamin Root
formatter = FuncFormatter(lambda x, pos: "%d" % x/10)
fig, ax = plt.subplots()ax.yaxis.set_major_formatter(formatter)plt.plot(D.dtrajs[0])
plt.ylabel('O2-Fe distance')
plt.xlabel('Frame')
plt.show()
Post by Sterling Smith
Christian,
To define your x coordinate, try
x = range(len(array))
x = x/10.
plot(x,array)
-Sterling
My array does not have an explicit x-coordinate
representation. The x-coordinate is simply the index.
print(array)
[ 0 0 20 ..., 8 8 8]
Thus what I would like is to adjoin the element
index as another row, how is this possible?
I cannot format x because it is not explicitly defined.
Ok, this really should be simple (and I am sure it is), but I cannot,
for the life of me, find the appropriate documentation for it. We need
better documentation about how to utilize the offset-text feature of
tickers. It can be either a multiple offset or an additive offset.
In any case, I know there is a better way to do this, but here is a
quick-n-dirty example that can get you where you want. Just modify the
formatter used by the tickers to report the value as divided by 10.
http://matplotlib.org/examples/pylab_examples/custom_ticker1.html
Cheers!
Ben Root
How can I scale my x-axis [0,3000] for the data to now correspond/show
up
as [0, 300]?
In xmgrace, this is done with a linear transformation, but I cannot seem
to find the command to do this with matplotlib.
Best
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your hub
for all
things parallel software development, from weekly thought leadership
blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
_______
Christian JÞrgensen
--
_______
Christian JÞrgensen
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your hub
for all
things parallel software development, from weekly thought leadership
blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now.
http://goparallel.sourceforge.net/_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
_______

Christian JÞrgensen
Christian Jorgensen
2015-03-09 18:40:38 UTC
Permalink
Sterling,

this doesn't work, as it's using the array as a function

x = D.dtrajs[0](range(len(D.dtrajs[0])))

plt.plot(D.dtrajs[0])

plt.ylabel('O2-Fe distance')

plt.xlabel('Frame')



---------------------------------------------------------------------------TypeError
Traceback (most recent call
last)<ipython-input-147-8bbee6b254c1> in <module>()----> 1 x =
D.dtrajs[0](range(len(D.dtrajs[0]))) 2 plt.plot(D.dtrajs[0])
3 plt.ylabel('O2-Fe distance') 4 plt.xlabel('Frame')
TypeError: 'numpy.ndarray' object is not callable
Post by Christian Jorgensen
Thanks,
I ran Benjamin's code but it doesn't display the
figure anymore. It only prints a text about the figure
formatter = FuncFormatter(lambda x, pos: "%d" % x/10)
fig, ax = plt.subplots()
ax.yaxis.set_major_formatter(formatter)
plt.plot(D.dtrajs[0])
plt.ylabel('O2-Fe distance')
plt.xlabel('Frame')
plt.show()
<matplotlib.figure.Figure at 0x11b1f2090>
Post by Benjamin Root
formatter = FuncFormatter(lambda x, pos: "%d" % x/10)
fig, ax = plt.subplots()ax.yaxis.set_major_formatter(formatter)plt.plot(D.dtrajs[0])
plt.ylabel('O2-Fe distance')
plt.xlabel('Frame')
plt.show()
Post by Sterling Smith
Christian,
To define your x coordinate, try
x = range(len(array))
x = x/10.
plot(x,array)
-Sterling
My array does not have an explicit x-coordinate
representation. The x-coordinate is simply the index.
print(array)
[ 0 0 20 ..., 8 8 8]
Thus what I would like is to adjoin the element
index as another row, how is this possible?
I cannot format x because it is not explicitly defined.
Ok, this really should be simple (and I am sure it is), but I cannot,
for the life of me, find the appropriate documentation for it. We need
better documentation about how to utilize the offset-text feature of
tickers. It can be either a multiple offset or an additive offset.
In any case, I know there is a better way to do this, but here is a
quick-n-dirty example that can get you where you want. Just modify the
formatter used by the tickers to report the value as divided by 10.
http://matplotlib.org/examples/pylab_examples/custom_ticker1.html
Cheers!
Ben Root
On Mon, Mar 9, 2015 at 1:38 PM, Christian Jorgensen<
How can I scale my x-axis [0,3000] for the data to now correspond/show
up
as [0, 300]?
In xmgrace, this is done with a linear transformation, but I cannot
seem
to find the command to do this with matplotlib.
Best
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your hub
for all
things parallel software development, from weekly thought leadership
blogs to
news, videos, case studies, tutorials and more. Take a look and join
the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
_______
Christian JÞrgensen
--
_______
Christian JÞrgensen
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your hub
for all
things parallel software development, from weekly thought leadership
blogs to
news, videos, case studies, tutorials and more. Take a look and join
the
conversation now.
http://goparallel.sourceforge.net/_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
_______
Christian JÞrgensen
--
_______

Christian JÞrgensen
Christian Jorgensen
2015-03-09 18:49:06 UTC
Permalink
I want to thank the users for their invaluable help.




My final error concerns the plotting:



<ipython-input-157-043a2bfb8704> in <lambda>(x, pos)----> 1 formatter
= FuncFormatter(lambda x, pos: "%d" % x/10) 2 3 fig, ax =
plt.subplots() 4 ax.yaxis.set_major_formatter(formatter) 5
a= plt.plot(D.dtrajs[0])
TypeError: unsupported operand type(s) for /: 'str' and 'int'
Post by Christian Jorgensen
Sterling,
this doesn't work, as it's using the array as a function
x = D.dtrajs[0](range(len(D.dtrajs[0])))
plt.plot(D.dtrajs[0])
plt.ylabel('O2-Fe distance')
plt.xlabel('Frame')
---------------------------------------------------------------------------TypeError Traceback (most recent call last)<ipython-input-147-8bbee6b254c1> in <module>()----> 1 x = D.dtrajs[0](range(len(D.dtrajs[0]))) 2 plt.plot(D.dtrajs[0]) 3 plt.ylabel('O2-Fe distance') 4 plt.xlabel('Frame')
TypeError: 'numpy.ndarray' object is not callable
Post by Christian Jorgensen
Thanks,
I ran Benjamin's code but it doesn't display the
figure anymore. It only prints a text about the figure
formatter = FuncFormatter(lambda x, pos: "%d" % x/10)
fig, ax = plt.subplots()
ax.yaxis.set_major_formatter(formatter)
plt.plot(D.dtrajs[0])
plt.ylabel('O2-Fe distance')
plt.xlabel('Frame')
plt.show()
<matplotlib.figure.Figure at 0x11b1f2090>
Post by Benjamin Root
formatter = FuncFormatter(lambda x, pos: "%d" % x/10)
fig, ax = plt.subplots()ax.yaxis.set_major_formatter(formatter)plt.plot(D.dtrajs[0])
plt.ylabel('O2-Fe distance')
plt.xlabel('Frame')
plt.show()
Post by Sterling Smith
Christian,
To define your x coordinate, try
x = range(len(array))
x = x/10.
plot(x,array)
-Sterling
My array does not have an explicit x-coordinate
representation. The x-coordinate is simply the index.
print(array)
[ 0 0 20 ..., 8 8 8]
Thus what I would like is to adjoin the element
index as another row, how is this possible?
I cannot format x because it is not explicitly defined.
Ok, this really should be simple (and I am sure it is), but I cannot,
for the life of me, find the appropriate documentation for it. We need
better documentation about how to utilize the offset-text feature of
tickers. It can be either a multiple offset or an additive offset.
In any case, I know there is a better way to do this, but here is a
quick-n-dirty example that can get you where you want. Just modify the
formatter used by the tickers to report the value as divided by 10.
http://matplotlib.org/examples/pylab_examples/custom_ticker1.html
Cheers!
Ben Root
On Mon, Mar 9, 2015 at 1:38 PM, Christian Jorgensen<
How can I scale my x-axis [0,3000] for the data to now
correspond/show up
as [0, 300]?
In xmgrace, this is done with a linear transformation, but I cannot
seem
to find the command to do this with matplotlib.
Best
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your
hub for all
things parallel software development, from weekly thought leadership
blogs to
news, videos, case studies, tutorials and more. Take a look and join
the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
_______
Christian JÞrgensen
--
_______
Christian JÞrgensen
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your
hub for all
things parallel software development, from weekly thought leadership
blogs to
news, videos, case studies, tutorials and more. Take a look and join
the
conversation now.
http://goparallel.sourceforge.net/_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
_______
Christian JÞrgensen
--
_______
Christian JÞrgensen
--
_______

Christian JÞrgensen
Benjamin Root
2015-03-09 18:57:24 UTC
Permalink
You might need to put parentheses around the statement for the lambda...

formatter = FuncFormatter(lambda x, pos: ("%d" % x/10))

Also, a tweak to my code. Change most of the "plt" to "ax" and use the
appropriate methods. I suspect that the ipython session you are in is
messing up the pyplot state machine and so being explicit for which axes
object you are operating on can prevent those blank plots.

ax.plot(D.dtrajs[0])

ax.set_ylabel('O2-Fe distance')

ax.set_xlabel('Frame')

plt.show()


Cheers!
Ben Root
Post by Christian Jorgensen
I want to thank the users for their invaluable help.
<ipython-input-157-043a2bfb8704> in <lambda>(x, pos)----> 1 formatter = FuncFormatter(lambda x, pos: "%d" % x/10) 2 3 fig, ax = plt.subplots() 4 ax.yaxis.set_major_formatter(formatter) 5 a= plt.plot(D.dtrajs[0])
TypeError: unsupported operand type(s) for /: 'str' and 'int'
Post by Christian Jorgensen
Sterling,
this doesn't work, as it's using the array as a function
x = D.dtrajs[0](range(len(D.dtrajs[0])))
plt.plot(D.dtrajs[0])
plt.ylabel('O2-Fe distance')
plt.xlabel('Frame')
---------------------------------------------------------------------------TypeError Traceback (most recent call last)<ipython-input-147-8bbee6b254c1> in <module>()----> 1 x = D.dtrajs[0](range(len(D.dtrajs[0]))) 2 plt.plot(D.dtrajs[0]) 3 plt.ylabel('O2-Fe distance') 4 plt.xlabel('Frame')
TypeError: 'numpy.ndarray' object is not callable
Post by Christian Jorgensen
Thanks,
I ran Benjamin's code but it doesn't display the
figure anymore. It only prints a text about the figure
formatter = FuncFormatter(lambda x, pos: "%d" % x/10)
fig, ax = plt.subplots()
ax.yaxis.set_major_formatter(formatter)
plt.plot(D.dtrajs[0])
plt.ylabel('O2-Fe distance')
plt.xlabel('Frame')
plt.show()
<matplotlib.figure.Figure at 0x11b1f2090>
Post by Benjamin Root
formatter = FuncFormatter(lambda x, pos: "%d" % x/10)
fig, ax = plt.subplots()ax.yaxis.set_major_formatter(formatter)plt.plot(D.dtrajs[0])
plt.ylabel('O2-Fe distance')
plt.xlabel('Frame')
plt.show()
Post by Sterling Smith
Christian,
To define your x coordinate, try
x = range(len(array))
x = x/10.
plot(x,array)
-Sterling
My array does not have an explicit x-coordinate
representation. The x-coordinate is simply the index.
print(array)
[ 0 0 20 ..., 8 8 8]
Thus what I would like is to adjoin the element
index as another row, how is this possible?
I cannot format x because it is not explicitly defined.
Ok, this really should be simple (and I am sure it is), but I
cannot, for the life of me, find the appropriate documentation for it. We
need better documentation about how to utilize the offset-text feature of
tickers. It can be either a multiple offset or an additive offset.
In any case, I know there is a better way to do this, but here is a
quick-n-dirty example that can get you where you want. Just modify the
formatter used by the tickers to report the value as divided by 10.
http://matplotlib.org/examples/pylab_examples/custom_ticker1.html
Cheers!
Ben Root
On Mon, Mar 9, 2015 at 1:38 PM, Christian Jorgensen<
How can I scale my x-axis [0,3000] for the data to now
correspond/show up
as [0, 300]?
In xmgrace, this is done with a linear transformation, but I cannot
seem
to find the command to do this with matplotlib.
Best
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your
hub for all
things parallel software development, from weekly thought leadership
blogs to
news, videos, case studies, tutorials and more. Take a look and join
the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
_______
Christian JÞrgensen
--
_______
Christian JÞrgensen
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your
hub for all
things parallel software development, from weekly thought leadership
blogs to
news, videos, case studies, tutorials and more. Take a look and join
the
conversation now.
http://goparallel.sourceforge.net/_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
--
_______
Christian JÞrgensen
--
_______
Christian JÞrgensen
--
_______
Christian JÞrgensen
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Loading...