1

marker font seems to have a sizing algorithm dependent on length. I want to research this myself BUT don't know where to start? The code line is below and I send about 12 symbols to it and the font size changes. How do I step through this problem and find the root cause for it please?

plt.plot(x,y,lw=2.5,color='g',linestyle='solid',marker=r"$\mathsf{%s}$" % symbol, markersize=30,
     markeredgewidth=1, markeredgecolor='k' , markerfacecolor= 'None')

here is the output from sending 12 different symbols to it ie AAPL, AIG,C

enter image description here

theakson
  • 502
  • 7
  • 23
  • The simplest, albeit not most accurate way, is to multiply markersize by the number of characters in your marker. –  May 10 '16 at 22:13
  • hey there. I can program round it it's just I can't see why it's happening. That's my question, what is the best way to determine why this is happening as the size should not alter at all once I specify it – theakson May 10 '16 at 22:54
  • Does this happen if you aren't using TeX for the marker? – cphlewis May 10 '16 at 23:29
  • hi there trying to keep the code simple so I haven't tried anything BUT TeX. I can code around it but I was going to use this as a learning experience in how debug things. I am new to matplotlib and this will be my first foray into looking into this type of thing. thanks for the interest though – theakson May 11 '16 at 03:07

2 Answers2

1

If you vary markersize with the number of characters, the font is the same size:

for t in (1,2,3):
    plt.plot([t*a for a in x], y, marker=r"$\mathsf{%s}$" % (t*'A'), markersize=10*t)

enter image description here

I guess the width is constant either if specified as a constant or if unspecified (must be a constant default) and the font size gets adjusted to fit.

Now, how to have figured that out... I kept throwing things out to make a minimal complete example, and just looked at what changed and thought about it.

cphlewis
  • 15,759
  • 4
  • 46
  • 55
  • hi @cphlewis thanks but I was not referring to how to code the issue out more how to step through the matplotlib code to determine the root cause of the issue. My thoughts were that if you stipulate 30 then the adjustments should be made to compensate for the varying text lengths. Thanks for the reply though. – theakson May 11 '16 at 03:04
  • Are you asking how to use a debugger? – cphlewis May 11 '16 at 19:56
  • hey there nope happy with debuggers since 1988 :-) it's the matplotlib thing I am having problems with. Right now it's datetime64 issues. I don't want to use Pandas ( don't ask) and I am LOVING Python, really is an excellent language. Thanks for your help it really was useful. – theakson May 12 '16 at 22:23
1

so I FINALLY found a possible explanation to my problem by THINKING about what I was REALLY asking. I found the answer

"This can be a somewhat confusing way of defining the size but you are basically specifying the area of the marker. This means, to double the width (or height) of the marker you need to increase s by a factor of 4. [because A = WH => (2W)(2H)=4A] "

here.

enter link description here

Community
  • 1
  • 1
theakson
  • 502
  • 7
  • 23