This question already has an answer here:
I am applying to PhD programs in astronomy this fall, and I will need letters of recommendation. I have been working with a research group for about a year, have done a poster session at a major conference based on work I have done with this group and have written a piece of software that will be used in a collaboration with another group at a different university. In these examples I worked most closely with a post doc in the group, but the PI was aware of what we were doing. The PI is well respected and widely known in the field, and the post doc recently received a prestigious and well known fellowship.
I am unsure whether to ask the post doc (who knows me better) or the professor (who knows me but is also more established in the field) for a letter of recommendation. I am in the fortunate position that I have more potential letter writers than I need, so I would prefer to have only one from this research position to show the breadth of my other research experience. Would I be better suited by asking the PI or the post doc? Is it common to have jointly written letters?