# textStim alignment alignHoriz alignVert

**URL:** <https://discourse.psychopy.org/t/textstim-alignment-alignhoriz-alignvert/4224>\
**Category:** Coding\
**Created:** [March 27, 2018, 7:03pm UTC](https://discourse.psychopy.org/t/textstim-alignment-alignhoriz-alignvert/4224 "2018-03-27T19:03:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![zykopathe](https://avatars.discourse-cdn.com/v4/letter/z/9fc348/32.png) [@zykopathe](https://discourse.psychopy.org/u/zykopathe)\
**Post date:** [March 27, 2018, 7:03pm UTC](https://discourse.psychopy.org/t/textstim-alignment-alignhoriz-alignvert/4224/1 "2018-03-27T19:03:31Z")

</div>

Hi all,

I’m very new at psychopy and try some builder and coder experiment.  
I’m working on mac os x 10.13.3 and psychopy 1.85.6.  
And…I’ve got a little problem.  
I played with testStim through coder and I was trying to align the text to the left with this code:

```auto
from psychopy import visual, core 
win = visual.Window()
msg = visual.TextStim(win,alignHoriz='left', height=0.1,wrapWidth=None, text=u"text text text text text text text text text text text text \ntext text text text \n\ntext .")
msg.draw()
win.flip()
core.wait(1)
win.close()

```

However, alignHoriz=‘left’ actually aligns the text to the…right!

 ![05](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/6/f/6f1d850dbeb2c1b39ea777ba8b2c784e63201a12.png)

I think I miss something essential but I don’t get it!  
What’s the tips ?

---

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [March 27, 2018, 9:32pm UTC](https://discourse.psychopy.org/t/textstim-alignment-alignhoriz-alignvert/4224/2 "2018-03-27T21:32:40Z")

</div>

> [@zykopathe](#):
>
> However, alignHoriz=‘left’ actually aligns the text to the…right!

Are you sure about that?

---

<div class="post-metadata">

**Author:** ![zykopathe](https://avatars.discourse-cdn.com/v4/letter/z/9fc348/32.png) [@zykopathe](https://discourse.psychopy.org/u/zykopathe)\
**Post date:** [March 28, 2018, 5:01am UTC](https://discourse.psychopy.org/t/textstim-alignment-alignhoriz-alignvert/4224/3 "2018-03-28T05:01:49Z")

</div>

To be honest…no ^^’  
I think I misunderstood something, as when I set alignHoriz=‘right’, I get this:

 ![31](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/c/f/cf96226d524f17c5862f2a93385c6c9a0f8b9ee2.png)

---

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [March 28, 2018, 5:28am UTC](https://discourse.psychopy.org/t/textstim-alignment-alignhoriz-alignvert/4224/4 "2018-03-28T05:28:31Z")

</div>

OK. I was confused too. I just did a bit of testing and it looks like that setting is not really about aligning the text _within_ the boundaries of the stimulus, but instead sets where the anchor point of the stimulus is. e.g. if the stimulus position is `[0, 0]`, then if alignment is `'center'` then the stimulus is centred horizontally on the screen (i.e. text will appear on either side of `0`). If it is `'left'`, then the left boundary of the stimulus is `0` (i.e. all text will be on the right half of the screen). Conversely, if alignment is `'right`', then the right boundary of the stimulus is `0`, and all text will be to the left of it.

No, it doesn’t seem obvious, and maybe the documentation needs to be edited accordingly?

---

<div class="post-metadata">

**Author:** ![zykopathe](https://avatars.discourse-cdn.com/v4/letter/z/9fc348/32.png) [@zykopathe](https://discourse.psychopy.org/u/zykopathe)\
**Post date:** [March 28, 2018, 6:13am UTC](https://discourse.psychopy.org/t/textstim-alignment-alignhoriz-alignvert/4224/5 "2018-03-28T06:13:32Z")

</div>

I first had a headache while reading your reply but then, I began to understand…  
If I understand correctly `pos` and `alignHoriz` work together: `alignHoriz` will align the stimulus from the position defined by `pos`?

Indeed, I do not find this very obvious - but I’m a beginner 😉

---

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [March 28, 2018, 7:14am UTC](https://discourse.psychopy.org/t/textstim-alignment-alignhoriz-alignvert/4224/6 "2018-03-28T07:14:13Z")

</div>

> [@](#):
>
> alignHoriz will align the stimulus from the position defined by pos?

It looks like it.

> [@](#):
>
> I do not find this very obvious - but I’m a beginner

Don’t worry, I don’t get it either.

---

<div class="post-metadata">

**Author:** ![zykopathe](https://avatars.discourse-cdn.com/v4/letter/z/9fc348/32.png) [@zykopathe](https://discourse.psychopy.org/u/zykopathe)\
**Post date:** [March 28, 2018, 8:32am UTC](https://discourse.psychopy.org/t/textstim-alignment-alignhoriz-alignvert/4224/7 "2018-03-28T08:32:47Z")

</div>

Thanks for the clarification!
