To edit a file, use a scriptable text editor, such as Ed or Ex (both POSIX editors). The syntax is very similar.
printf '%s\n' '/^import matplotlib as mpl$/d' 's/mpl/plt' 'w' 'q' | ed -s file
printf '%s\n' '/^import matplotlib as mpl$/d' 's/mpl/plt' 'x' | ex file
printf '%s\n'supplies commands to the editor./^import matplotlib as mpl$/ddeletes the first line matching the pattern.s/mpl/pltperforms the substitution on the next line.wandqorxsave the changes.
If you really want Sed,
sed '/^import matplotlib as mpl$/N; s/.*\nmpl/plt/' file
Addressing your expanded question:
find /path/to/dir/ -type f -exec sh -c '
printf "%s\n" "/^import matplotlib as mpl\$/d" "s/mpl/plt" "w" "q" |
ed -s "$1"' sh {} \;