plt scale x-axis by constant factor f

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
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
_______

Christian Jørgensen

···

On Mon, Mar 9, 2015 at 5:52 PM, Benjamin Root <ben.root@...1304...> wrote:

On Mon, Mar 9, 2015 at 1:38 PM, Christian Jorgensen <chrisjorg@...287...> >> wrote:

--
_______

Christian Jørgensen

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?

···

On Mon, Mar 9, 2015 at 1:57 PM, Christian Jorgensen <chrisjorg@…120…287…> wrote:


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

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

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.


Christian Jørgensen

On Mon, Mar 9, 2015 at 5:52 PM, Benjamin Root <ben.root@…1304…> wrote:

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


Christian Jørgensen

On Mon, Mar 9, 2015 at 1:38 PM, Christian Jorgensen <chrisjorg@…287…> wrote:

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

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Christian,

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

-Sterling

···

On Mar 9, 2015, at 10:57AM, Christian Jorgensen <chrisjorg@...287...> wrote:

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.

On Mon, Mar 9, 2015 at 5:52 PM, Benjamin Root<ben.root@...1304...> wrote:
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<chrisjorg@...287...> wrote:
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
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
_______

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
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

That was untested. It should start with (still untested)

x = array(range(len(array))

···

On Mar 9, 2015, at 11:11AM, Sterling Smith <smithsp@...3304...> wrote:

Christian,

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

-Sterling

On Mar 9, 2015, at 10:57AM, Christian Jorgensen <chrisjorg@...287...> wrote:

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.

On Mon, Mar 9, 2015 at 5:52 PM, Benjamin Root<ben.root@...1304...> wrote:
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<chrisjorg@...287...> wrote:
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
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
_______

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
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

------------------------------------------------------------------------------
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
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

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()
···

On Mon, Mar 9, 2015 at 2:11 PM, Sterling Smith <smithsp@…3304…> wrote:

Christian,

To define your x coordinate, try

x = range(len(array))

x = x/10.

plot(x,array)

-Sterling

On Mar 9, 2015, at 10:57AM, Christian Jorgensen <chrisjorg@…287…> wrote:

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.

On Mon, Mar 9, 2015 at 5:52 PM, Benjamin Root<ben.root@…1304…> wrote:

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<chrisjorg@…287…> wrote:

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

Matplotlib-users@lists.sourceforge.net

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

Matplotlib-users@lists.sourceforge.net

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

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

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>
···

On Mon, Mar 9, 2015 at 6:16 PM, Benjamin Root <ben.root@…1304…> wrote:

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()

On Mon, Mar 9, 2015 at 2:11 PM, Sterling Smith <smithsp@…3304…> wrote:

Christian,

To define your x coordinate, try

x = range(len(array))

x = x/10.

plot(x,array)

-Sterling

On Mar 9, 2015, at 10:57AM, Christian Jorgensen <chrisjorg@…287…> wrote:

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.

On Mon, Mar 9, 2015 at 5:52 PM, Benjamin Root<ben.root@…1304…> wrote:

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<chrisjorg@…287…> wrote:

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

Matplotlib-users@lists.sourceforge.net

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

Matplotlib-users@lists.sourceforge.net

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

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Christian Jørgensen

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')


<details class='elided'>
<summary title='Show trimmed content'>&#183;&#183;&#183;</summary>

On Mon, Mar 9, 2015 at 6:35 PM, Christian Jorgensen <chrisjorg@...287...> wrote:
> 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>
> ```

> 

> 

> 

--

On Mon, Mar 9, 2015 at 6:16 PM, Benjamin Root <ben.root@...1304...> wrote:
> 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()
> ```
> 

_______

Christian Jørgensen

--

On Mon, Mar 9, 2015 at 2:11 PM, Sterling Smith <smithsp@...3304...> wrote:
> Christian,
> 
> 
> 
> To define your x coordinate, try
> 
> x = range(len(array))
> 
> x = x/10.
> 
> plot(x,array)
> 
> 
> 
> -Sterling
> 
> 
> 
> On Mar 9, 2015, at 10:57AM, Christian Jorgensen <chrisjorg@...287...> wrote:
> 
> 
> 
> >
> 
> > 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.
> 
> >
> 
> >
> 
> >
> 
> > On Mon, Mar 9, 2015 at 5:52 PM, Benjamin Root<ben.root@...1304...> wrote:
> 
> > 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](http://matplotlib.org/examples/pylab_examples/custom_ticker1.html)
> 
> >
> 
> > Cheers!
> 
> > Ben Root
> 
> >
> 
> >
> 
> > On Mon, Mar 9, 2015 at 1:38 PM, Christian Jorgensen<chrisjorg@...287...> wrote:
> 
> > 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/](http://goparallel.sourceforge.net/)
> 
> > _______________________________________________
> 
> > Matplotlib-users mailing list
> 
> > Matplotlib-users@lists.sourceforge.net
> 
> > [https://lists.sourceforge.net/lists/listinfo/matplotlib-users](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/_______________________________________________](http://goparallel.sourceforge.net/_______________________________________________)
> 
> > Matplotlib-users mailing list
> 
> > Matplotlib-users@lists.sourceforge.net
> 
> > [https://lists.sourceforge.net/lists/listinfo/matplotlib-users](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/](http://goparallel.sourceforge.net/)
> 
> _______________________________________________
> 
> Matplotlib-users mailing list
> 
> Matplotlib-users@lists.sourceforge.net
> 
> [https://lists.sourceforge.net/lists/listinfo/matplotlib-users](https://lists.sourceforge.net/lists/listinfo/matplotlib-users)

_______

Christian Jørgensen

</details>
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'



···

On Mon, Mar 9, 2015 at 6:40 PM, Christian Jorgensen <chrisjorg@…287…> wrote:

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

On Mon, Mar 9, 2015 at 6:35 PM, Christian Jorgensen <chrisjorg@…287…> wrote:

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>

Christian Jørgensen

On Mon, Mar 9, 2015 at 6:16 PM, Benjamin Root <ben.root@…1304…> wrote:

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()

Christian Jørgensen

On Mon, Mar 9, 2015 at 2:11 PM, Sterling Smith <smithsp@…3304…> wrote:

Christian,

To define your x coordinate, try

x = range(len(array))

x = x/10.

plot(x,array)

-Sterling

On Mar 9, 2015, at 10:57AM, Christian Jorgensen <chrisjorg@…287…> wrote:

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.

On Mon, Mar 9, 2015 at 5:52 PM, Benjamin Root<ben.root@…1304…> wrote:

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<chrisjorg@…287…> wrote:

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

Matplotlib-users@lists.sourceforge.net

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

Matplotlib-users@lists.sourceforge.net

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

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Christian Jørgensen

You might need to put parentheses around the statement for the lambda…

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

ax.plot(D.dtrajs[0])
ax.set_ylabel('O2-Fe distance')
ax.set_xlabel('Frame')
plt.show()

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.

Cheers!

Ben Root

···

On Mon, Mar 9, 2015 at 2:49 PM, Christian Jorgensen <chrisjorg@…287…> wrote:

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'







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

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

On Mon, Mar 9, 2015 at 6:40 PM, Christian Jorgensen <chrisjorg@…287…> wrote:

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


Christian Jørgensen

On Mon, Mar 9, 2015 at 6:35 PM, Christian Jorgensen <chrisjorg@…985…> wrote:

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>

Christian Jørgensen

On Mon, Mar 9, 2015 at 6:16 PM, Benjamin Root <ben.root@…1304…> wrote:

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()

Christian Jørgensen

On Mon, Mar 9, 2015 at 2:11 PM, Sterling Smith <smithsp@…3304…> wrote:

Christian,

To define your x coordinate, try

x = range(len(array))

x = x/10.

plot(x,array)

-Sterling

On Mar 9, 2015, at 10:57AM, Christian Jorgensen <chrisjorg@…287…> wrote:

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.

On Mon, Mar 9, 2015 at 5:52 PM, Benjamin Root<ben.root@…1304…> wrote:

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<chrisjorg@…287…> wrote:

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

Matplotlib-users@lists.sourceforge.net

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

Matplotlib-users@lists.sourceforge.net

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

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users