On Sat, Feb 28, 2009 at 9:59 PM, per freem <perfreem@...> wrote:
> hi JaeJoon,
>
> thanks again, that makes sense.
>
> final question on this plot  i am trying to plot what we discussed but am
> getting very strange results.
>
> all i am trying to do is produce a scatter plot like:
>
> http://www2.warwick.ac.uk/fac/sci/moac/degrees/modules/ch923/r_introduction/scatter_plots/scatter.png
>
> where the key feature is that the first x tick and first y tick are not at
> the origin but spaced a bit away from it (and both equally spaced from it)
> and similarly for the last x and last y tick (which should be a bit before
> the end of the x and y axes.)
>
> if i plot on linux, i get the pdf attached as linux.pdf. if i plot on mac os
> x, i get the one attached as mac.pdf. aside from the differences in fonts,
> the linux pdf is lower quality where the ticks and the surrounding box of
> the plot have different thicknesses, which make the graph look strange.
> also, the xaxis labels are correctly spaced out from the ticks in the
> linux.pdf but not in the mac os x. overall, the mac pdf is of higher quality
> but the spacing is messed up.
Linux v.s Mac does not make much sense. What version of maplotlib do
you use in each platform? The rc file in two platform are identical?
They are both pdf files, it does not make much sense that one of them
has a higher quality. Looking at your two pdf files, the ticks in
linux.pdf looks a bit more fuzzy, but as far as I can see, it seems to
me as some antialising effect.
If you think the tick lines are too fuzzy, you 'd better increase the
width of tick lines.
rcParams["lines.markeredgewidth"]=1. # default is 0.5
>
> how can i make the mac os x version space correctly, and make the linux
> version better looking?
I don't think there is nothing wrong with the mac version. But see
below. Again, if you think the tick lines are too fuzzy, increase the
line width.
>
> the code is simply:
>
> def axes_square(plot_handle):
> plot_handle.axes.set_aspect(1/plot_handle.axes.get_data_ratio())
>
> fig = figure()
> rcParams['xtick.direction'] = 'out'
> rcParams['ytick.direction'] = 'out'
> s = subplot(1,3,1)
> x = arange(0,1,.01)
> y = arange(0,1,.01)+rand(100)
> axes_square(s)
>
> s = subplot(111)
> ax = plot(x, y, 'bo', markeredgecolor='blue', mfc='none')
>
> xlim(.05,1,1.05)
> ylim(.05,1,1.05)
Are the linux.pdf and mac.pdf created with a same script?
The linux one seems to have xrange of 0.05~1.05 while the mac one has
xrange of 0.05~1. And according to your script, it should be
0.05~1.
What do you intend to do by "xlim(0.05, 1, 1.05)"? Why you a third
arguments? (I don't think you mean to set emit=True by this).
Maybe you just wanted "xlim(0.05, 1.05)"?
JJ
ps. I'm CCing this email to the list. Please CC to the list when you
reply so that the
conversation stays on the mailing list.
>
> savefig('filename.pdf')
>
> (so the only variability is the random vectors plotted)
>
> thanks again.
>>
>>
>> On Sat, Feb 28, 2009 at 6:22 PM, per freem <perfreem@...> wrote:
>> > hi,
>> >
>> > that code snippet works but it does not change the font. changing it to:
>> >
>> > def my_hash(self):
>> > l = ['Courier',
>> > self.get_style(),
>> > self.get_variant(),
>> > self.get_weight(),
>> > self.get_stretch(),
>> > self.get_size()]
>> >
>> > return hash(repr(l))
>> > fp = FontProperties(family="Lucida Sans Typewriter")
>> > fp.__hash__ = my_hash
>> >
>> > runs, but does not change the font either.
>> >
>> > would be very interested if you have any other ideas? thanks.
>> >
>> >
>> >
>> >
>> > On Sat, Feb 28, 2009 at 6:04 PM, JaeJoon Lee <lee.j.joon@...>
>> > wrote:
>> >>
>> >> On Sat, Feb 28, 2009 at 5:31 PM, per freem <perfreem@...> wrote:
>> >> > thank you for your reply. when i try either of the first suggestions
>> >> > about
>> >> > changing the fonts, i get the error:
>> >> >
>> >> > AttributeError: 'FontProperties' object has no attribute 'get_slant'
>> >> >
>> >> > any idea what this means?
>> >>
>> >> It seems that you're using v0.98.3 or before. See if following code
>> >> works.
>> >>
>> >> from matplotlib.font_manager import FontProperties
>> >>
>> >> def my_hash(self):
>> >> l = [self.get_family(),
>> >> self.get_style(),
>> >> self.get_variant(),
>> >> self.get_weight(),
>> >> self.get_stretch(),
>> >> self.get_size()]
>> >>
>> >> return hash(repr(l))
>> >>
>> >> FontProperties.__hash__ = my_hash
>> >>
>> >>
>> >>
>> >> >
>> >> > also, i do not mind setting the position of each tickmark
>> >> > individually
>> >> > but i
>> >> > cannot find a way to do this  could you please explain how this can
>> >> > be
>> >> > done?
>> >> >
>> >>
>> >>
>> >>
>> >> http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.xticks
>> >>
>> >>
>> >> http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.yticks
>> >>
>> >> JJ
>> >>
>> >>
>> >> > thanks again.
>> >> >
>> >> >
>> >> > On Sat, Feb 28, 2009 at 5:19 PM, JaeJoon Lee <lee.j.joon@...>
>> >> > wrote:
>> >> >>
>> >> >> > but it does not work. i tried similarly setting the font size
>> >> >> > (with
>> >> >> > set_size() or through rcParams) but it did not work either. how
>> >> >> > can i
>> >> >> > do
>> >> >> > this? i'd like to do this either on per axes basis, or for the
>> >> >> > entire
>> >> >> > figure.
>> >> >>
>> >> >> It seems that changing rcParams is not effective because of the way
>> >> >> how the font caching is done. Here is a little monkey patching to
>> >> >> change this behavior.
>> >> >>
>> >> >> from matplotlib.font_manager import FontProperties
>> >> >>
>> >> >> def my_hash(self):
>> >> >> l = dict([(k, getattr(self, "get" + k)()) for k in
>> >> >> self.__dict__])
>> >> >> return hash(repr(l))
>> >> >>
>> >> >> FontProperties.__hash__ = my_hash
>> >> >>
>> >> >>
>> >> >> With this code, changing rcParams will affect (most of) the text in
>> >> >> the
>> >> >> figure.
>> >> >>
>> >> >> As far as I know, you cannot have a default font properties on per
>> >> >> axes basis. You need to manually change the font properties of Text
>> >> >> artists in your interests.
>> >> >>
>> >> >> For example, to change the font properties of the xtick labels,
>> >> >>
>> >> >> fp = FontProperties(family="Lucida Sans Typewriter")
>> >> >> ax = gca()
>> >> >> for t in ax.get_xticklabels():
>> >> >> t.set_fontproperties(fp)
>> >> >>
>> >> >>
>> >> >> >
>> >> >> > second, how can i make it so axes labels do not overlap? in many
>> >> >> > plots,
>> >> >> > including ones in the gallery, you see the labels at the origin of
>> >> >> > plots
>> >> >> > get
>> >> >> > too close to each other. (i.e. the 0.0 of xaxis and 0.0 of
>> >> >> > yaxis) 
>> >> >> > how
>> >> >> > can you prevent this from happening?
>> >> >> >
>> >> >>
>> >> >> I don't think there is a smart way to prevent it other than manually
>> >> >> changing the tick positions. Other may have better ideas.
>> >> >>
>> >> >> JJ
>> >> >
>> >> >
>> >
>> >
>
>
